#K5601. Interval Conflict Checker

    ID: 30103 Type: Default 1000ms 256MiB

Interval Conflict Checker

Interval Conflict Checker

You are given a set of intervals on the number line. Each interval is represented by two integers (a) and (b) (with (a < b)) indicating the start and end of the interval. Two intervals ([a, b]) and ([c, d]) are considered to be in conflict (i.e. overlapping) if (c < b) when the intervals are sorted by their start time. Your task is to determine if any two of the given intervals overlap (i.e. there is a conflict).

Formally, if the intervals after sorting by their start times are (I_1, I_2, \ldots, I_n) with (I_i = [a_i, b_i]), then a conflict exists if there exists an index (i) ((2 \leq i \leq n)) such that (a_i < b_{i-1}).

Print True if there is any conflict and False otherwise.

inputFormat

The input is read from standard input (stdin) and has the following format:

(n) — The number of intervals.

Followed by (n) lines, each containing two integers (a) and (b) representing an interval. It is guaranteed that (a < b).

outputFormat

Output to standard output (stdout) a single line containing either True if there exists at least one pair of overlapping intervals, or False otherwise.## sample

4
1 5
6 10
15 20
5 6
False