#P16101. [ICPC 2019 NAIPC] Intersecting Rectangles

[ICPC 2019 NAIPC] Intersecting Rectangles

题目描述

You are given a set of nn 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} :::

In this example, only rectangles A and B intersect.

输入格式

Each test case will begin with a line with a single integer nn (1n1051 \leq n \leq 10^5), which is the number of rectangles.

Each of the next nn lines will contain four space-separated integers:

x1 y1 x2 y2x_1\ y_1\ x_2\ y_2

(109x1,y1,x2,y2109-10^9 \leq x_1, y_1, x_2, y_2 \leq 10^9, x1<x2x_1 < x_2, y1<y2y_1 < y_2), which describe a rectangle, where (x1,y1)(x_1, y_1) is the lower left corner and (x2,y2)(x_2, y_2) is the upper right corner. All xx values will be distinct. All yy values will be distinct.

输出格式

Output a single integer, which is 11 if some pair of rectangles intersect, 00 if no pair of rectangles intersect.

3
0 0 2 2
1 1 3 4
5 7 6 8
1
4
0 0 20 20
1 1 3 4
2 10 9 12
11 3 19 18
0