【题目链接】: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. bzoj2982 combination——卢卡斯定理

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2982 卢卡斯定理裸题: 原准备1A来着,结果输出忘了加回车! 预处理阶乘或者现求都可以,感觉 ...

  3. Sublime Text 汉化插件

    https://blog.csdn.net/heyangyi_19940703/article/details/51869502 一.Sublime Text工具介绍: Sublime Text 是一 ...

  4. [Swift通天遁地]五、高级扩展-(2)扩展集合类型

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

  5. web自动化测试—selenium游览器下拉框操作

    # coding=utf-8'''下拉框实战思路导包:from selenium.webdriver.support.select import Select #下拉框select from sele ...

  6. 你真的知道GET和POST两种基本请求方法的区别吗?

    GET和POST是HTTP请求的两种基本方法,要说它们的区别,接触过WEB开发的人都能说出一二. 最直观的区别就是GET把参数包含在URL中,POST通过request body传递参数. 你可能自己 ...

  7. Highcharts Highstock 学习笔记 第一篇 Highcharts配置

    Highcharts是一款纯javascript编写的图表库,能够很简单便捷的在Web网站或Web应用中添加交互性的图表,Highcharts目前支持直线图.曲线图.面积图.柱状图.饼图.散点图等多达 ...

  8. java定时器和实时查询数据库

    定时器: Timer timer = new Timer();                    timer.schedule(new TimerTask() {                  ...

  9. PAT甲级1016Phone Bills

    #include<iostream> #include<cstdio> #include<cstdlib> #include<vector> #incl ...

  10. Hive扩展功能(八)--表的索引

    软件环境: linux系统: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8 主机配置: 一共m1, m2, m3这三部机, 每部主机的用户名都为centos ...