QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#3007. Intersecting Rectangles

统计

Problem Description

You are given a set of $n$ axis-aligned rectangles in a $\text{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.

In this example, only rectangles $\textbf{A}$ and $\textbf{B}$ intersect.

Input

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

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

Samples

Sample Input 1

3
0 0 2 2
1 1 3 4
5 7 6 8

Sample Output 1

1

Sample Input 2

4
0 0 20 20
1 1 3 4
2 10 9 12
11 3 19 18

Sample Output 2

0
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.