CF763B.Timofey and rectangles
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different colors in such a way that every two rectangles touching each other by side would have different color, or determine that it is impossible.
Two rectangles intersect if their intersection has positive area. Two rectangles touch by sides if there is a pair of sides such that their intersection has non-zero length
The picture corresponds to the first example
蒂莫费伊生日收到的一份礼物是一本形状为无限平面的涂色书。平面上放置了 n 个边与坐标轴平行的矩形,所有矩形的边长均为奇数。这些矩形互不相交(即交集面积为零),但可以彼此邻接(即边与边接触)。
请帮助蒂莫费伊用 4 种不同颜色为这些矩形着色,使得任意两个通过边邻接的矩形颜色均不相同;若无法实现,则判定其不可能。
两个矩形相交,当且仅当它们的交集具有正面积。
两个矩形通过边邻接,当且仅当存在一对边,其交集长度非零。
该图对应第一个样例
输入格式
The first line contains single integer n (1 ≤ n ≤ 5·105) — the number of rectangles.
n lines follow. The i-th of these lines contains four integers _x_1, _y_1, _x_2 and _y_2 ( - 109 ≤ _x_1 < _x_2 ≤ 109, - 109 ≤ _y_1 < _y_2 ≤ 109), that means that points (_x_1, _y_1) and (_x_2, _y_2) are the coordinates of two opposite corners of the i-th rectangle.
It is guaranteed, that all sides of the rectangles have odd lengths and rectangles don't intersect each other.
第一行包含一个整数 n(1≤n≤5⋅105)—— 矩形的数量。
接下来 n 行。其中第 i 行包含四个整数 x1、y1、x2 和 y2(−109≤x1<x2≤109,−109≤y1<y2≤109),表示第 i 个矩形的两个对角顶点坐标为 (x1,y1) 和 (x2,y2)。
保证所有矩形的边长均为奇数,且矩形之间互不相交。
输出格式
Print "NO" in the only line if it is impossible to color the rectangles in 4 different colors in such a way that every two rectangles touching each other by side would have different color.
Otherwise, print "YES" in the first line. Then print n lines, in the i-th of them print single integer c__i (1 ≤ c__i ≤ 4) — the color of i-th rectangle.
如果无法用 4 种不同颜色对矩形进行染色,使得任意两个以边相接的矩形颜色均不相同,则在唯一一行中输出 "NO"。
否则,在第一行输出 "YES";然后输出 n 行,其中第 i 行输出一个整数 c__i(1 ≤ c__i ≤ 4),表示第 i 个矩形的颜色。
输入输出样例
输入#1
8 0 0 5 3 2 -1 5 0 -3 -4 2 -1 -1 -1 2 0 -3 0 0 5 5 2 10 3 7 -3 10 2 4 -2 7 -1
输出#1
YES 1 2 2 3 2 2 4 1
输入解题思路,AI测评打分。不知道怎么写?