Mike and Fish CodeForces - 547D
As everyone knows, bears love fish. But Mike is a strange bear; He hates fish! The even more strange thing about him is he has an infinite number of blue and red fish.
He has marked n distinct points in the plane. i-th point is point (xi, yi). He wants to put exactly one fish in each of these points such that the difference between the number of red fish and the blue fish on each horizontal or vertical line is at most 1.
He can’t find a way to perform that! Please help him.
Input
The first line of input contains integer n (1 ≤ n ≤ 2 × 105).
The next n lines contain the information about the points, i-th line contains two integers xi and yi (1 ≤ xi, yi ≤ 2 × 105), the i-th point coordinates.
It is guaranteed that there is at least one valid answer.
Output
Print the answer as a sequence of n characters ‘r’ (for red) or ‘b’ (for blue) where i-th character denotes the color of the fish in the i-th point.
Example
Input
4
1 1
1 2
2 1
2 2
Output
brrb
Input
3
1 1
1 2
2 1
Output
brr
思路:
摘自 < %popoqq >
补充一点
题目大意:给定平面上的n个点,要求将每个点染成红色/蓝色,使得每行/每列的红色点数和蓝色点数之差≤1。
坐标系中的问题,考虑把x坐标和y坐标分成两个集合,将每一个横坐标/纵坐标看做一个点,每个点看做一条连接两个坐标的边。
现在我们要将每条边染色使得每个点连接的所有边中两种颜色之差≤1。
考虑用二分图解题,在二分图中任意找一