麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

codeforces 763B. Timofey and rectangles [思維]【智商】

2019-11-14 08:46:33
字體:
來源:轉載
供稿:網友

題目連接:http://codeforces.com/PRoblemset/problem/763/B

——————————————————————————————-. time limit per test2 seconds memory limit per test256 megabytes

inputstandard input outputstandard output

One of Timofey’s birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.

Help Timofey to color his rectangles in 4 different colors in such a way that every two rectangles touching each other by side would have different color, or determine that it is impossible.

Two rectangles intersect if their intersection has positive area. Two rectangles touch by sides if there is a pair of sides such that their intersection has non-zero length

The picture corresponds to the first example Input The first line contains single integer n (1?≤?n?≤?5·105) — the number of rectangles.

n lines follow. The i-th of these lines contains four integers x1, y1, x2 and y2 (?-?109?≤?x1?<?x2?≤?109, ?-?109?≤?y1?<?y2?≤?109), that means that points (x1,?y1) and (x2,?y2) are the coordinates of two opposite corners of the i-th rectangle.

It is guaranteed, that all sides of the rectangles have odd lengths and rectangles don’t intersect each other.

Output Print “NO” in the only line if it is impossible to color the rectangles in 4 different colors in such a way that every two rectangles touching each other by side would have different color.

Otherwise, print “YES” in the first line. Then print n lines, in the i-th of them print single integer ci (1?≤?ci?≤?4) — the color of i-th rectangle.

Example

input

8 0 0 5 3 2 -1 5 0 -3 -4 2 -1 -1 -1 2 0 -3 0 0 5 5 2 10 3 7 -3 10 2 4 -2 7 -1

output

YES 1 2 2 3 2 2 4 1

——————————————————————————————-. 題目大意: 就是在一個二維平面上有n個矩形,現在讓你給這n個矩形4種涂色之一,使得相鄰的矩形顏色不同. (矩形的兩條邊都是整數) 解題思路:

我這種智障是做不出來的,本來并不想寫題解,但是無意中看了Tutorial中的discuss發現一個特別容易理解的.

We may assume that our rectangles are drawn on an infinite sheet of squared paper. Divide it into squares 2 × 2 and mark the cells in each square by 1, 2, 3, 4 clockwise starting from the upper left corner. Since both sides of each rectangle are of odd length, its corner cells are marked by the same number. Let us number four different colors by 1, 2, 3, 4 and paint each rectangle with the color whose number marks the corner cells. It is readily seen that the numbers in the corners of any two adjacent rectangles are distinct. 我們可能會認為我們的矩形被畫在無限平方的紙。將紙分成一個個2×2方塊,然后從左上角順時針方向開始標上1,2,3,4(代表顏色)。由于每個矩形的兩邊都是奇數長度,所以它的所有格子標記為相同的數。讓我們用1,2,3,4個不同的顏色編號,并繪制每個矩形的顏色的數字標記的格子。很容易看出,任何兩個相鄰矩形的角的數是不同的。 (基本是機翻……可以自己畫一畫就容易理解了,Orz)

附本題代碼 ——————————————————————————————-.

int main(){ int x1,x2,y1,y2; int n ; s1(n);puts("YES"); Rep(i,1,n){ s1(x1),s1(x2),s1(y1),s1(y2); x1=(x1%2+2)%2; x2=(x2%2+2)%2; printf("%d/n",x1+x2*2+1); } return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日日鲁一鲁视频 | 毛片在线免费观看完整版 | 在线播放h | 亚洲一区二区三区四区精品 | 久啪视频 | 亚洲一二区视频 | sesee99| 欧美一区二区三区免费不卡 | 国产一区二区视频在线播放 | 午夜影视一区二区 | 精品一区二区在线观看视频 | 黄在线观看| 5xsq在线视频 | 操碰视频在线观看 | 极色品影院 | 精品国产一区二区三区四区在线 | 国产成人在线网站 | 精品国产一区三区| 线观看免费完整aaa 欧美在线一级 | 免费看成年人网站 | 日韩不卡一区二区 | 久久久久久久久久性 | 亚洲人成网站在e线播放 | 亚洲一区二区三区视频免费 | 亚洲成人高清电影 | 黄色的视频在线观看 | 亚洲网站免费观看 | 亚洲午夜久久久精品一区二区三区 | 欧美城网站地址 | 神马久久精品综合 | 欧美精品a∨在线观看不卡 午夜精品影院 | h色视频网站 | 中午字幕无线码一区2020 | 亚洲一级毛片 | 国产精品亚洲欧美一级在线 | 欧美国产一区二区三区 | 蜜桃av鲁一鲁一鲁一鲁 | 日韩毛片一区二区三区 | 奶子吧naiziba.cc免费午夜片在线观看 | 操碰| 久久毛片 |