Description

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

Input

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.

Output

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.

Example
input
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
output
YES
1
2
2
3
2
2
4
1
题意:问能不能被四种颜色标记地图
解法:四色问题,当然是YES,现在考虑如何染色
我们看左下角如果都是奇数,因为长度是奇数,所以其他的x,y都是偶数,那么其他以奇数为左下角的都不会有交集
嗯,四种颜色嘛。。奇偶排列刚好是四种,于是。。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<"YES"<<endl;
for(int i=;i<=n;i++)
{
int x,y,a,b;
cin>>x>>y>>a>>b;
if(x%&&y%)
{
cout<<""<<endl;
}
else if(x%==&&y%)
{
cout<<""<<endl;
}
else if(x%&&y%==)
{
cout<<""<<endl;
}
else if(x%==&&y%==)
{
cout<<""<<endl;
}
}
return ;
}

Codeforces Round #395 (Div. 2) D的更多相关文章

  1. Codeforces Round #395 (Div. 2)(A.思维,B,水)

    A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:stan ...

  2. Codeforces Round #395 (Div. 2) D. Timofey and rectangles

    地址:http://codeforces.com/contest/764/problem/D 题目: D. Timofey and rectangles time limit per test 2 s ...

  3. Codeforces Round #395 (Div. 2) C. Timofey and a tree

    地址:http://codeforces.com/contest/764/problem/C 题目: C. Timofey and a tree time limit per test 2 secon ...

  4. Codeforces Round #395 (Div. 2)B. Timofey and cubes

    地址:http://codeforces.com/contest/764/problem/B 题目: B. Timofey and cubes time limit per test 1 second ...

  5. Codeforces Round #395 (Div. 1)

    比赛链接:http://codeforces.com/contest/763 A题: #include <iostream> #include <cstdio> #includ ...

  6. Codeforces Round #395 (Div. 2)(未完)

    2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> ...

  7. Codeforces Round #395 (Div. 2)

    今天自己模拟了一套题,只写出两道来,第三道时间到了过了几分钟才写出来,啊,太菜了. A. Taymyr is calling you 水题,问你在z范围内  两个序列  n,2*n,3*n...... ...

  8. 【分类讨论】Codeforces Round #395 (Div. 2) D. Timofey and rectangles

    D题: 题目思路:给你n个不想交的矩形并别边长为奇数(很有用)问你可以可以只用四种颜色给n个矩形染色使得相接触的 矩形的颜色不相同,我们首先考虑可不可能,我们分析下最多有几个矩形互相接触,两个时可以都 ...

  9. 【树形DP】Codeforces Round #395 (Div. 2) C. Timofey and a tree

    标题写的树形DP是瞎扯的. 先把1看作根. 预处理出f[i]表示以i为根的子树是什么颜色,如果是杂色的话,就是0. 然后从根节点开始转移,转移到某个子节点时,如果其子节点都是纯色,并且它上面的那一坨结 ...

  10. Codeforces Round #395 (Div. 2) C

    题意 : 给出一颗树 每个点都有一个颜色 选一个点作为根节点 使它的子树各自纯色 我想到了缩点后check直径 当<=3的时候可能有解 12必定有解 3的时候需要check直径中点的组成点里是否 ...

随机推荐

  1. 信雅达面试题atoi函数实现

    atoi函数: 功 能: 把字符串转换成整型数. 名字来源:ASCII to integer 的缩写. 原型: int atoi(const char *nptr); 函数说明 参数nptr字符串,如 ...

  2. ARC机制之__strong具体解释

    ARC机制之__strong具体解释 __strong  解析: 默认情况下,一个指针都会使用 __strong 属性,表明这是一个强引用.这意味着,仅仅要引用存在,对象就不能被销毁.这是一种所期望的 ...

  3. python day-3 基本数据类型

    1. 编码 1. 最早的计算机编码是ASCII. 美国人创建的. 包含了英文字母(大写字母, 小写字母). 数字, 标点等特殊字符!@#$% 128个码位 2**7 在此基础上加了一位 2**8 8位 ...

  4. TGraphiControl响应WM_MOUSEMOVE的过程(以TPaintBox为例)good

    起因:非Windows句柄控件也可以处理鼠标消息,我想知道是怎么处理的:并且想知道处理消息的顺序(比如TPaintBox和TForm都响应WM_Mouse消息该怎么办)界面:把TPaintBox放到T ...

  5. Window XP安装Ubuntu14.04实现Samba文件共享

    安装了Ubuntu14.04之后,在虚拟机设置里设置了文件共享.但在mnt文件夹下没有hgfs这个文件夹.依照网上说的去做还是不行,仅仅好放弃.改用samba实现Windows与Ubuntu文件共享. ...

  6. java上传文件,提交表单必须要设置enctype="multipart/form-data"

    表单中enctype="multipart/form-data"的意思,是设置表单的MIME编码.默认情况,这个编码格式是application/x-www-form-urlenc ...

  7. react native 知识点总结(一)

    一.关于react native 版本的升级 参照文档:http://reactnative.cn/docs/0.45/upgrading.html react-native -v   查看当前版本 ...

  8. react native 中的redux

    一.使用redux 的条件: 1.某个组件的状态,需要共享: 2.某个状态需要在任何地方都可以拿到: 3.一个组件需要改变全局状态: 4.一个组件需要改变另一个组件的状态. redux   说明白点, ...

  9. 字符串查找函数(BF)

    //模拟字符串定位函数 // s: abcbbghi // t: ghi // 返回6 #include <iostream> #include <string> #inclu ...

  10. PHP——巧用PHP函数array_merge()合并数组

    前言 返回联系人列表,包含所有的字母,之前返回的是存在这个联系人才会返回对应的大写字母,后面更改了要求要返回所有的字母从A-Z.PHP内置的一些函数活用起来,真的很省劲! 步骤 一般这时候大家可能直接 ...