CF335D.Rectangles and Square
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n rectangles, labeled 1 through n. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle).
Your task is to determine if there's a non-empty subset of the rectangles that forms a square. That is, determine if there exists a subset of the rectangles and some square for which every point that belongs to the interior or the border of that square belongs to the interior or the border of at least one of the rectangles in the subset, and every point that belongs to the interior or the border of at least one rectangle in the subset belongs to the interior or the border of that square.
给你 n 个矩形,编号为 1 到 n。每个矩形的顶点坐标均为整数,且其边分别与 Ox 轴和 Oy 轴平行。这些矩形可以相互接触,但不能重叠(即不存在同时属于多个矩形内部的点)。
你的任务是判断是否存在一个非空矩形子集,使得该子集恰好拼成一个正方形。换言之,判断是否存在一个矩形子集以及某个正方形,满足以下两个条件:
- 该正方形的内部或边界上的任意一点,都至少落在该子集中某个矩形的内部或边界上;
- 该子集中任一矩形的内部或边界上的任意一点,都落在该正方形的内部或边界上。
输入格式
First line contains a single integer n (1 ≤ n ≤ 105) — the number of rectangles. Each of the next n lines contains a description of a rectangle, with the i-th such line describing the rectangle labeled i. Each rectangle description consists of four integers: _x_1, _y_1, _x_2, _y_2 — coordinates of the bottom left and the top right corners (0 ≤ _x_1 < _x_2 ≤ 3000, 0 ≤ _y_1 < _y_2 ≤ 3000).
No two rectangles overlap (that is, there are no points that belong to the interior of more than one rectangle).
第一行包含一个整数 n(1≤n≤105)—— 矩形的数量。接下来的 n 行每行描述一个矩形,其中第 i 行描述编号为 i 的矩形。每个矩形的描述由四个整数 x1,y1,x2,y2 组成,分别表示其左下角和右上角的坐标(0≤x1<x2≤3000,0≤y1<y2≤3000)。
任意两个矩形互不重叠(即不存在属于多于一个矩形内部的点)。
输出格式
If such a subset exists, print "YES" (without quotes) on the first line of the output file, followed by k, the number of rectangles in the subset. On the second line print k numbers — the labels of rectangles in the subset in any order. If more than one such subset exists, print any one. If no such subset exists, print "NO" (without quotes).
如果存在这样的子集,则在输出文件的第一行打印 "YES"(不带引号),后跟子集中矩形的个数 k;第二行打印 k 个数字——子集中矩形的编号(顺序任意)。如果存在多个满足条件的子集,输出任意一个即可。如果不存在这样的子集,则打印 "NO"(不带引号)。
输入输出样例
输入#1
9 0 0 1 9 1 0 9 1 1 8 9 9 8 1 9 8 2 2 3 6 3 2 7 3 2 6 7 7 5 3 7 6 3 3 5 6
输出#1
YES 5 5 6 7 8 9
输入#2
4 0 0 1 9 1 0 9 1 1 8 9 9 8 1 9 8
输出#2
NO
说明/提示
The first test case looks as follows:

Note that rectangles 6, 8, and 9 form a square as well, and would be an acceptable answer.
The second test case looks as follows:

第一个测试用例如下所示:

注意:矩形 6、8 和 9 同样构成一个正方形,因此也是一个可接受的答案。
第二个测试用例如下所示:

输入解题思路,AI测评打分。不知道怎么写?