【题目链接】: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. go语言笔记——切片底层本质是共享数组内存!!!绝对不要用指针指向 slice切片本身已经是一个引用类型就是指针

    切片 切片(slice)是对数组一个连续片段的引用(该数组我们称之为相关数组,通常是匿名的),所以切片是一个引用类型(因此更类似于 C/C++ 中的数组类型,或者 Python 中的 list 类型) ...

  2. 创建 /dev/video0 节点 (转载)

    转自:http://blog.csdn.net/linuxmake/article/details/8208464 最近做摄像头驱动,发现没有 /dev/video0节点,经过查看发现是内核编译时没有 ...

  3. Knights of the Round Table(Tarjan+奇圈)

    http://poj.org/problem?id=2942 题意:n个武士,某些武士之间相互仇视,如果在一起容易发生争斗事件.所以他们只有满足一定的条件才能参加圆桌会议:(1)相互仇视的两个武士不能 ...

  4. [Swift通天遁地]六、智能布局-(2)视图对象的尺寸和位置相对约束

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  5. Python基础类型(二) str 字符串

    字符串str ' ' 字符串+ 都是字符串的时候才能相加 a = 'alex' b = 'wusir' print(a+b) #字符串拼接 字符串* 字符串和数字相乘 a = 6 b = 'alex' ...

  6. 返回Json和XML两种格式

    由于项目需要,同一接口支持根据参数不同返回XML和Json两种格式的数据,在网上看了很多大多是加后缀的方式来实现返回不同格式数据的,后来看了一篇http://www.importnew.com/276 ...

  7. 记一次MySQL索引优化

    两张表是主(CHECK_DRAWINGS)从(CHECK_DRAWINGS_IMG)关系. CHECK_DRAWINGS,主表数据 3591条. SELECT COUNT(*) FROM CHECK_ ...

  8. 【洛谷2469/BZOJ1927】[SDOI2010]星际竞速(费用流/最小路径覆盖)

    题目: 洛谷2469 分析: 把题目翻译成人话:给一个带边权的DAG,求一个路径覆盖方案使路径边权总和最小.从点\(i\)开始的路径需要额外加上\(A_i\)的权值. 回xian忆chang一xue下 ...

  9. day03_12/13/2016_bean的管理之作用域与初始化时间

    在Spring中,Bean有几种作用域: 1.singleton作用域 当一个bean的作用域设置为singleton,那么Spring IOC容器中只会存在一个共享的bean实例,并且所有对bean ...

  10. Spring Cloud (10) Hystrix-监控面板

    Hystrix DashBoard 断路器是根据一段时间窗内的请求状况来判断并操作断路器的打开和关闭状态的.Hystrix Dashboard是作为断路器状态的一个组件,提供了数据监控和友好的图形化界 ...