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. Android安装应用后点击&quot;打开&quot;(Open)带来的问题及解决方案

    MainActivity例如以下: package cc.cc; import android.app.Activity; import android.content.Intent; import ...

  2. JVM手动分配内存(转载)

    原文内容很详细,不利于快速浏览,所以只保留了重点 原文地址 http://blog.csdn.net/mr__fang/article/details/47723767 内存检测工具jvisualVM ...

  3. weblogic 修改控制台console访问路径 url

    出于安全的考虑需要对weblogic的console进行屏避,或者修改默认的访问路径,主要有两种方法:(这里针对weblogic8.1) 一.进入默认的控制台,例如“localhost/console ...

  4. mybatis xml文件解析

    1 parameterType 如果参数只有一个,比如一个id,即int类型的id,那么parameterType直接是int. 如果参数有多个,那么就用表中一行对应的类,默认是类的名字和表中列的名字 ...

  5. easyui tree的简单使用

    Tree 数据转换 所有节点都包含以下属性: id:节点id,这个很重要到加载远程服务器数据 which is important to load remote data text: 显示的节点文本 ...

  6. Spring的声明式事务

    1.与hibernate集成 <bean id="sessionFactory" class="org.springframework.orm.hibernate3 ...

  7. 百度自然语言处理api用法

    def words url = "https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?access_token=1111111" param ...

  8. SQL Server 数据库备份策略,第一周运行失败的原因

    一般生产库,采用 每10分钟备份Log,每天备份Diff,每周备份Full的策略. 同时存在异地备份.异地备份可使用SQL Server本身的cmdshell存储过程,调用系统命令. 在为新数据库,建 ...

  9. js截取小数点后面2位

    1.substr var str = "Hello world!"; document.write(str.substr(3)); 输出:lo world! var str = & ...

  10. (转)windows下的Expdp、Impdp使用

    1 .Expdp windows下导出截图示范 2.impdp windows下导入截图示范 Impdp system/eas directory=EASBAK dumpfile=stjt_10060 ...