P16101 [ICPC 2019 NAIPC] Intersecting Rectangles

Description

You are given a set of $n$ axis-aligned rectangles in a 2D plane. For this problem, two rectangles are considered to intersect if their boundaries contain any common points (in particular, two nesting rectangles don’t count as intersecting). Determine if some pair of rectangles intersect. :::align{center} ![](https://cdn.luogu.com.cn/upload/image_hosting/vjmztebq.png) ::: In this example, only rectangles **A** and **B** intersect.

Input Format

Each test case will begin with a line with a single integer $n$ ($1 \leq n \leq 10^5$), which is the number of rectangles. Each of the next $n$ lines will contain four space-separated integers: $$ x_1\ y_1\ x_2\ y_2 $$ ($-10^9 \leq x_1, y_1, x_2, y_2 \leq 10^9$, $x_1 < x_2$, $y_1 < y_2$), which describe a rectangle, where $(x_1, y_1)$ is the lower left corner and $(x_2, y_2)$ is the upper right corner. All $x$ values will be distinct. All $y$ values will be distinct.

Output Format

Output a single integer, which is $1$ if some pair of rectangles intersect, $0$ if no pair of rectangles intersect.