Codeforces Round #395 (Div. 2) D. Timofey and rectangles
来源:互联网 发布:淘宝客导购网站有哪些 编辑:程序博客网 时间:2024/05/23 00:03
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 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 x1, y1, x2 and y2 ( - 109 ≤ x1 < x2 ≤ 109, - 109 ≤ y1 < y2 ≤ 109), that means that points (x1, y1) and (x2, y2) 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.
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 ci (1 ≤ ci ≤ 4) — the color of i-th rectangle.
80 0 5 32 -1 5 0-3 -4 2 -1-1 -1 2 0-3 0 0 55 2 10 37 -3 10 24 -2 7 -1
YES12232241
其实不难。。因为边长肯定是奇数,所以只有左下点坐标全奇,全偶或一奇一偶这四种情况互相之间才有可能有边相邻
全奇和全偶之间就不说了,
全奇和一奇一偶,举个例子
x偶y奇
1 1 4 4
4 1 3 2
x奇y偶
1 1 4 4
1 4 2 5
全偶和一奇一偶
x偶y奇
0 0 3 3
0 3 1 4
x奇y偶
0 0 3 3
3 0 4 1
#include<stdio.h>#include<math.h>int x[500005],y[500005];int main(){int n,i,a,b;scanf("%d",&n);for(i=0;i<n;i++)scanf("%d %d %d %d",&x[i],&y[i],&a,&b);printf("YES\n");for(i=0;i<n;i++){if(x[i]&1&&y[i]&1)printf("1\n");else if(x[i]&1&&!(y[i]&1))printf("2\n");else if(!(x[i]&1)&&y[i]&1)printf("3\n");else printf("4\n");}return 0;}
这次做的很差,光怼c还没怼出来,d也直接弃了,
看题一定要看清题意!!!不要遗漏!!!
无论什么题,都要思考至少五分钟在决定是否跳过!!
好好学英语。。。。。。。。。。。。。。。。。。。。。。。。。。
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles
- Codeforces Round #395 (Div. 2)D. Timofey and rectangles
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles
- Codeforces Round #395 (Div. 2)-D. Timofey and rectangles
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles(思路)
- Codeforces Round #395(Div. 2)D. Timofey and rectangles【思维】好题!
- Codeforces Round #395 (Div. 2) D Timofey and rectangles(思维题)
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles_0
- CodeForces 764D Timofey and rectangles【四色问题】
- Codeforces Round #395 (Div. 2) C. Timofey and a tree
- Codeforces Round #395 (Div. 2)Timofey and cubes
- Codeforces Round #395 (Div. 2)Timofey and a tree
- Codeforces Round #395(Div. 2)B. Timofey and cubes【模拟】
- Codeforces Round #395 (Div. 2) C. Timofey and a tree
- D. Timofey and rectangles
- Codeforces Round #395 (Div. 1) D Timofey and a flat tree (树hash)
- 【Codeforces Round395】 Codeforces 764D Timofey and rectangles
- leetcode 39. Combination Sum
- 【WordPress头条】你不得不看的国产wp主题精选推荐
- Eclipse4.X版本安装ECLIPSE 打包插件fatjar
- parseInt函数
- LeetCode 371. Sum of Two Integers
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles
- 最简单的Ogre系列之二——画线
- unity中屏幕和世界坐标系区别
- Codeforces 764C或763A Timofey and a tree 【好题】
- GRUB启动分析之stage1
- Java细粒度锁实现的3种方式
- Centos7 ifconfig这个命令没找到的解决方法
- Codeforces Round #395 (Div. 2)D. Timofey and rectangles
- GRUB启动分析之stage1.5