【codeforces 764D】Timofey and rectangles
【题目链接】: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的更多相关文章
- 【codeforces 764B】Timofey and cubes
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 764C】Timofey and a tree
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【45.65%】【codeforces 560B】Gerald is into Art
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【84.62%】【codeforces 552A】Vanya and Table
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 764A】Taymyr is calling you
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
随机推荐
- XAML实例教程系列 - 开篇(一)
XAML实例教程系列 - 开篇 2012-05-14 11:47 by jv9, 5588 阅读, 8 评论, 收藏, 编辑 去年,曾答应银光中国论坛的朋友推出一个关于XAML语言实例教程系列,帮助学 ...
- [BZOJ 3126] Photo
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=3126 [算法] 差分约束系统 注意SPFA判负环的条件应为 : 若所有点入队次数之和 ...
- 2017 nodeJS
一.版本迅速更新 Chrome浏览器已经蹦到57版本了,是名副其实的版本帝,作为兄弟的Node.js也一样,1.0之前等了6年,而从1.0到8.0,只用了2年时间,现在已到9以上了 我们就数一下 从v ...
- compileSdkVersion, minSdkVersion 和 targetSdkVersion的选择(copy)
英文原文:Picking your compileSdkVersion, minSdkVersion, and targetSdkVersion 作者:Ian Lake,Google Android ...
- 将本地文件复制到hadoop文件系统
package com.yoyosys.cebbank.bdap.service.mr; import java.io.BufferedInputStream; import java.io.File ...
- NS2学习笔记(二)
Tcl语言 变量和变量赋值 set a "Hello World!" #将字符串赋值给变量a puts "NS2 say $a" #输出字符串的内容,其中$a表 ...
- flask web 表单验证 WTForms
简介 WTForms 是一个flask集成框架,或者说是库,用于处理浏览器表单提交的数据,它在flask-WTF的基础上扩展并添加了一些随手可得的精巧帮助函数,这些函数将会是在flask里使用表单更加 ...
- 深入Mysql字符集设置
作者: Laruence( ) 本文地址: http://www.laruence.com/2008/01/05/12.html 转载请注明出处 根据Chaos Wang的PPT整理而成, 在此 ...
- 设置靠近 水平居中的主体内容Div 的 左侧位置固定的Div
示例效果: 1.主体内容的divMain 水平居中: 2.divLeft 靠近divMain ,位置固定,不随垂直滚动条而动: 相关代码: <html> <head runat=&q ...
- C# Autofac 出现 尝试创建“XXController”类型的控制器时出错。请确保控制器具有无参数公共构造函数 错误解决方案
出现以下错误: 总结解决方案: 本项目采用构造函数方法进行依赖注入,由于个人原因在业务层相互注入了接口,导致交叉:报错