Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/boolean-kesmalar-kesishadimi

Do the segments intersect?

Medium 1000 ms 64 MB 38%
Share

Two segments $[a; b]$ and $[c; d]$ are given on the number line. The ends of a segment belong to it too. Check whether the statement is true: “the segments have at least one common point”. For example, the segments $[1; 3]$ and $[3; 7]$ meet at the point $3$.

The overlap of two segments on the number line

Input

One line with four integers: $a$, $b$, $c$ and $d$.

Output

One integer: $1$ if the statement is true, otherwise $0$.

Note

$-10^{9} \le a \le b \le 10^{9}$
$-10^{9} \le c \le d \le 10^{9}$

Examples

Input #1
1 5 3 8
Output #1
1
Input #2
1 2 4 6
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.