Codeforces Round #395 (Div. 2) D. Timofey and rectangles 思维题

D. Timofey and rectangles

链接:

http://codeforces.com/contest/764/problem/D

题解:

因为矩形的边为奇数长度 
根据四色定理,染色一定会成功。

(1)我们只看左下角坐标,如果两个数值都为奇数,那么右上角坐标一定两个都为偶数,所以所有左下标坐标为奇数的不会相交,可赋值为1。

(2) 如果x轴为偶数,可能与1的情况左右相邻赋值为2。

(3)如果y轴为偶数,可能与1的情况左右相邻,赋值为3。

(4)其余赋值为4。

代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int a, b, c, d, n;
 8     cin >> n;
 9     printf("YES\n");
10     while (n--)
11     {
12         scanf("%d%d%d%d", &a, &b, &c, &d);
13         if (a % 2 && b % 2) printf("1\n");
14         else if (a % 2 == 0 && b % 2) printf("2\n");
15         else if (a % 2 && b % 2 == 0) printf("3\n");
16         else printf("4\n");
17     }
18     return 0;
19 }

 

posted @ 2017-02-13 23:04  Flowersea  阅读(159)  评论(0编辑  收藏  举报