【题目链接】:http://codeforces.com/contest/764/problem/D

【题意】



给你n个矩形,以左下角坐标和右上角坐标的形式给出;

(保证矩形的边长为奇数)

问你有没有染色方案,使得这n个矩形,任意两个相邻矩形的颜色不一样;

(只有4种颜色可以选择);

【题解】



因为矩形的边长为奇数;

所以对于左下角来说;

右上角的横纵坐标的奇偶性分别和左下角的横纵坐标的奇偶性都不同;

(因为一个数加上奇数之后奇偶性发生改变);

按照这个原理;

我们只要考虑左下角那个坐标就好了;

根据左下角坐标(x,y)

的x,y的奇偶性分为4种情况;

就分别对应了4种颜色;

分别染色1,2,3,4就好了;

(可以想一下,左下角横纵坐标奇偶性相同的话,肯定不会相邻的)



【Number Of WA】



0



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
#define ref(x) scanf("%lf",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110; int n; int main()
{
//freopen("F:\\rush.txt","r",stdin);
puts("YES");
rei(n);
rep1(i,1,n)
{
int x0,y0,x1,y1;
rei(x0),rei(y0),rei(x1),rei(y1);
if (x0<0) x0 = -x0;
if (y0<0) y0 = -y0;
if (x0%2==1 && y0%2==1) puts("1");
if (x0%2==1 && y0%2==0) puts("2");
if (x0%2==0 && y0%2==1) puts("3");
if (x0%2==0 && y0%2==0) puts("4");
}
//printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
return 0;
}

【codeforces 764D】Timofey and rectangles的更多相关文章

  1. 【codeforces 764B】Timofey and cubes

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. 【codeforces 764C】Timofey and a tree

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  4. 【45.65%】【codeforces 560B】Gerald is into Art

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【84.62%】【codeforces 552A】Vanya and Table

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 764A】Taymyr is calling you

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  8. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  9. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

随机推荐

  1. YTU 2720: 删出多余的空格

    2720: 删出多余的空格 时间限制: 1 Sec  内存限制: 128 MB 提交: 338  解决: 201 题目描述 小平在给弟弟检查英语作业时时,发现每个英语句子单词之间的空格个数不等,请你编 ...

  2. go语言笔记——多值函数,本质上和nodejs的回调很像,不过nodejs是回调的第一个参数是err,而golang里是第二个!

    5.2 测试多返回值函数的错误 Go 语言的函数经常使用两个返回值来表示执行是否成功:返回某个值以及 true 表示成功:返回零值(或 nil)和 false 表示失败(第 4.4 节).当不使用 t ...

  3. [模板]FWT

    写起来和fft很像,这里放个板子. 代码: #include<iostream> #include<cstdio> #include<cmath> #include ...

  4. Luogu4198 楼房重建

    https://zybuluo.com/ysner/note/1124880 题面 带修改的区间维护最大斜率. 题面 解析 用线段树区间维护斜率. 考虑如何向上合并. 左半段一定有贡献. 如果左半段的 ...

  5. ubuntu16.04 Kafka 安装

    Kafka核心概念: 下面介绍Kafka相关概念,以便运行下面实例的同时,更好地理解Kafka. 1. Broker Kafka集群包含一个或多个服务器,这种服务器被称为broker 2. Topic ...

  6. 编译android4.4 报错error: call to '__property_get_too_small_error' declared with attribute 的处理 (转载)

    转自:http://blog.csdn.net/syhost/article/details/14448899 完整的报错为: system/core/include/cutils/propertie ...

  7. Tornado异步模式

    先介绍下背景:由于工作需要,前段时间又写了一段爬虫去获取和更新一些数据.之前爬虫主要用Scrapy框架批量爬取一些页面数据,或者用Gevent调用目标站点的接口.偶然看到了Tornado,听说这个框架 ...

  8. 这里有最全的C/C++入门到进阶书籍推荐,你需要嘛?

    编程是操作性很强的一门知识,看书少不了,但只有学习和实践相结合才能起到很好的效果,一种学习方法是看视频->看书->研究书中例子->自己做些东西->交流->看书. 研究经典 ...

  9. akka设计模式系列-actor锚定

    actor锚定模式是指使用actorSelection对acor进行锚定的设计模式,也可以说是一个对actor的引用技巧.在某些情况下,我们可能需要能够根据Actor的path锚定对应的实例.简单来说 ...

  10. 在vue项目npm run build后,index.html中引入css和js 报MIME type问题

    问题: 1.在vue项目中,build打包后,index页面打开会报错, MIME type ('text/html') ;报错内容:because its MIME type ('text/html ...