CF763B Timofey and Rectangles】的更多相关文章

题目戳这里. 首先答案肯定是YES,因为一个平面图肯定可以被4种颜色染色,关键是怎么输出方案. 由于4是一个特殊的数字\(4 = 2^2\),而我们还有一个条件就是边长为奇数,而奇数是会改变二进制位的. 接下来我们这样思考,对于每个矩形我们设其左下角坐标为\((x,y)\),我们把他染成\((x\;mod\;2)\times2+(y\;mod\;2)\).由于边长是奇数,所以相邻矩形二进制位至少有一位不一样.然后这题就做完了. #include<iostream> #include<cs…
地址:http://codeforces.com/contest/764/problem/D 题目: D. Timofey and rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One of Timofey's birthday presents is a colourbook in a shape o…
D题: 题目思路:给你n个不想交的矩形并别边长为奇数(很有用)问你可以可以只用四种颜色给n个矩形染色使得相接触的 矩形的颜色不相同,我们首先考虑可不可能,我们分析下最多有几个矩形互相接触,两个时可以都互相接触 三个时也可以互相接触,而四个时怎么摆我们都不能让他们相互都接触,所以我们最多可以用三种不同颜色 的矩形去接触另一个矩形,因此我们就一定可以用四种颜色来染色,然后我们来考虑怎么染色,因为不存在相 交的情况,所以就拿左下角来分析,首先我们来分析下, 1,两个矩形要上下接触时:我们考虑纵坐标,因…
[题目链接]:http://codeforces.com/contest/764/problem/D [题意] 给你n个矩形,以左下角坐标和右上角坐标的形式给出; (保证矩形的边长为奇数) 问你有没有染色方案,使得这n个矩形,任意两个相邻矩形的颜色不一样; (只有4种颜色可以选择); [题解] 因为矩形的边长为奇数; 所以对于左下角来说; 右上角的横纵坐标的奇偶性分别和左下角的横纵坐标的奇偶性都不同; (因为一个数加上奇数之后奇偶性发生改变); 按照这个原理; 我们只要考虑左下角那个坐标就好了:…
%%题解,脑洞好大啊. 四色定理什么鬼的..所以一定是yes. 因为矩形边长都是奇数,所以可以按左下角分类,一共4类,分别1,2,3,4就可以了. (需要4种颜色的情况大概就是4个矩形围起来一个矩形) #include<bits/stdc++.h> #define LL long long #define N 100005 #define lowbit(x) x&(-x) using namespace std; inline int ra() { ,f=; char ch=getch…
2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; ; inline int read(){ ,f=; ; c=getcha…
今天自己模拟了一套题,只写出两道来,第三道时间到了过了几分钟才写出来,啊,太菜了. A. Taymyr is calling you 水题,问你在z范围内  两个序列  n,2*n,3*n......  和 m,2*m,3*m.....有多少个是一样的. #include<bits/stdc++.h> using namespace std; int n,m,z; int main() { cin>>n>>m>>z; int gcd=__gcd(n,m);…
题目地址: http://poj.org/problem?id=1314 题意: 给出一串的点,有些点可以构成正方形,请按照字符排序输出. 因为这道题的用处很大, 最近接触的cv 中的Rectangle Detection 中就有方法使用到了这个算法. 但实际中使用的算法还是暴力. 不过因为数据点较少,可以直接快排之后,再来个迭代,就得到答案了 #include <cstdio> #include <iostream> #include <cstring> #inclu…
Description We are given a figure consisting of only horizontal and vertical line segments. Our goal is to count the number of all different rectangles formed by these segments. As an example, the number of rectangles in the Figures 1 and 2 are 5 and…
题目链接: B. Searching Rectangles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Filya just learned new geometry object — rectangle. He is given a field consisting of n × n unit cells. Rows ar…