CF763B Timofey and Rectangles
题目戳这里。
首先答案肯定是YES,因为一个平面图肯定可以被4种颜色染色,关键是怎么输出方案。
由于4是一个特殊的数字\(4 = 2^2\),而我们还有一个条件就是边长为奇数,而奇数是会改变二进制位的。
接下来我们这样思考,对于每个矩形我们设其左下角坐标为\((x,y)\),我们把他染成\((x\;mod\;2)\times2+(y\;mod\;2)\)。由于边长是奇数,所以相邻矩形二进制位至少有一位不一样。然后这题就做完了。
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int N;
inline int gi()
{
char ch; int ret = 0,f = 1;
do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
if (ch == '-') f = -1,ch = getchar();
do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
return ret*f;
}
int main()
{
freopen("763B.in","r",stdin);
freopen("763B.out","w",stdout);
puts("YES");
for (N = gi();N--;)
{
int X1 = gi(),Y1 = gi(),X2 = gi(),Y2 = gi();
if (X1 > X2) swap(X1,X2);
if (Y1 > Y2) swap(Y1,Y2);
printf("%d\n",(((X1&1)<<1)|(Y1&1))+1);
}
fclose(stdin); fclose(stdout);
return 0;
}
CF763B Timofey and Rectangles的更多相关文章
- 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 ...
- 【分类讨论】Codeforces Round #395 (Div. 2) D. Timofey and rectangles
D题: 题目思路:给你n个不想交的矩形并别边长为奇数(很有用)问你可以可以只用四种颜色给n个矩形染色使得相接触的 矩形的颜色不相同,我们首先考虑可不可能,我们分析下最多有几个矩形互相接触,两个时可以都 ...
- 【codeforces 764D】Timofey and rectangles
[题目链接]:http://codeforces.com/contest/764/problem/D [题意] 给你n个矩形,以左下角坐标和右上角坐标的形式给出; (保证矩形的边长为奇数) 问你有没有 ...
- cf 763B. Timofey and rectangles
%%题解,脑洞好大啊. 四色定理什么鬼的..所以一定是yes. 因为矩形边长都是奇数,所以可以按左下角分类,一共4类,分别1,2,3,4就可以了. (需要4种颜色的情况大概就是4个矩形围起来一个矩形) ...
- Codeforces Round #395 (Div. 2)(未完)
2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> ...
- Codeforces Round #395 (Div. 2)
今天自己模拟了一套题,只写出两道来,第三道时间到了过了几分钟才写出来,啊,太菜了. A. Taymyr is calling you 水题,问你在z范围内 两个序列 n,2*n,3*n...... ...
- poj-1314 Finding Rectangles
题目地址: http://poj.org/problem?id=1314 题意: 给出一串的点,有些点可以构成正方形,请按照字符排序输出. 因为这道题的用处很大, 最近接触的cv 中的Rectangl ...
- [ACM_暴力][ACM_几何] ZOJ 1426 Counting Rectangles (水平竖直线段组成的矩形个数,暴力)
Description We are given a figure consisting of only horizontal and vertical line segments. Our goal ...
- codeforces 713B B. Searching Rectangles(二分)
题目链接: B. Searching Rectangles time limit per test 1 second memory limit per test 256 megabytes input ...
随机推荐
- 微信程序跳转到页面底部 scroll-view
wx.createSelectorQuery().select('#j_page').boundingClientRect(function (rect) { wx.pageScrollTo({ sc ...
- CentOS下配置jdk
CentOS下配置jdk 1.在jdk官网上下载最新版本的jdk 2.将jdk放到相应的位置,使用如下命令来解压. .0_181 /opt/data/ tar -zxf jdk-8u181-linux ...
- 爬虫之request模块高级
一.cookie&session cookie:服务器端使用cookie来记录客户端的状态信息 实现流程: 执行登陆操作(获取cookie) 在发起个人主页请求时,需要将cookie携带到该请 ...
- linux 热替换so文件
http://www.zhaoch.top/操作系统/linux/热替换so文件.html 热替换so文件 www.zhaoch.top > 操作系统 > linux 发现nginx的动态 ...
- socket编程基础1——hostent、in_addr、gethostbyname、inet_ntoa
1. struct hostent结构体 struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; ...
- linux课后作业1
本实验6第一题:菜单驱动程序. 随便进到某个目录,vim driver.sh 把代码写进去. #!/bin/bash function welcome() { echo -e "\n&quo ...
- shell重温---基础篇(shell数组&数组操作)
上篇博客已经分析重温了shell的运行方式以及其中的变量还有字符串,之后按照套路就是数组方面了,废话不多说,直接进入正题哈.(小白笔记,各位看官勿喷...) bash shell呢,支持一位数 ...
- ChipScope软件使用
内容组织 1.建立工程 2.插入及配置核 2.1运行Synthesize 2.2新建cdc文件 2.3 ILA核的配置 3. Implement and generate programmi ...
- 当应用出现 access violation at address in module时
Delphi2010和XE10,midas是不同的版本,之前开发的两个系统,基于不同的Delphi版本,经常出现access violation at address in module错误.特别是当 ...
- 深度学习之卷积神经网络CNN
转自:https://blog.csdn.net/cxmscb/article/details/71023576 一.CNN的引入 在人工的全连接神经网络中,每相邻两层之间的每个神经元之间都是有边相连 ...