QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 1024 MB 總分: 100

#3007. 相交矩形

统计

给定平面上的 $n$ 个轴对齐矩形。在本题中,如果两个矩形的边界包含任何公共点,则认为它们相交(特别地,嵌套的两个矩形不计为相交)。请判断是否存在某一对矩形相交。

在此示例中,只有矩形 $\textbf{A}$ 和 $\textbf{B}$ 相交。

输入格式

每个测试用例的第一行包含一个整数 $n$ ($1 \leq n \leq 10^5$),表示矩形的数量。

接下来的 $n$ 行,每行包含四个空格分隔的整数:

$$ 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)$,描述了一个矩形,$(x_1, y_1)$ 为左下角坐标,$(x_2, y_2)$ 为右上角坐标。所有 $x$ 坐标互不相同,所有 $y$ 坐标互不相同。

输出格式

输出一个整数,如果存在某一对矩形相交,则输出 $1$,否则输出 $0$。

样例

输入格式 1

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

输出格式 1

1

输入格式 2

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

输出格式 2

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.