QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 128 MB 總分: 100

#16016. 矩形

统计

在平面上给出 $N$ 个矩形。矩形的边平行于坐标轴。这些矩形可能会重叠、重合或相互包含。它们的顶点具有非负整数坐标,且 $x$ 坐标不超过 $x_{\max}$,$y$ 坐标不超过 $y_{\max}$。

一条线段起点为点 $A(0, 0)$,终点为点 $B$。点 $B$(线段的另一端)的坐标满足以下条件:

  • 点 $B$ 的坐标为整数;
  • 点 $B$ 属于线段 $[(0, y_{\max}), (x_{\max}, y_{\max})]$ 或线段 $[(x_{\max}, 0), (x_{\max}, y_{\max})]$。

线段 $AB$ 可能会穿过矩形(我们假设即使只穿过矩形的一个顶点,也算作穿过)。

任务

编写一个程序,寻找一个点 $B$,使得线段 $AB$ 穿过尽可能多的矩形。

含有 8 个矩形的样例。线段 AB 穿过了其中的 5 个。

输入格式

输入第一行包含三个整数:$x_{\max}$,$y_{\max}$($0 < x_{\max}, y_{\max} \le 10^9$)和 $N$($1 \le N \le 10000$)。

接下来的 $N$ 行,每行包含四个整数:左下角坐标 $x_{bl}$ 和 $y_{bl}$,以及右上角坐标 $x_{tr}$ 和 $y_{tr}$。相邻的数字之间用单个空格分隔。

输出格式

输出的第一行也是唯一一行中应写入三个整数。首先是穿过的最大矩形数量,随后是点 $B$ 的 $x$ 和 $y$ 坐标。相邻的数字必须用单个空格分隔。

如果有多个解,输出其中任意一个即可。

样例

输入样例 1

22 14 8 
1 8 7 11 
18 10 20 12 
17 1 19 7 
12 2 16 3 
16 7 19 9 
8 4 12 11 
7 4 9 6 
10 5 11 6

输出样例 1

5 22 12

说明

另一个可能的解为:

5 22 11

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.