#P10097. [ROIR 2023] 彩点 (Day 1)
[ROIR 2023] 彩点 (Day 1)
Background
Translated from ROIR 2023 D1T4。
There are points on the plane, namely 。The coordinates of the -th point are 。
Choose two points ()。Let be the starting point and be the ending point。With the ending point as the center, starting from the direction of the vector , sort all points except in counterclockwise order (if angles are the same, sort by increasing distance to )。Suppose the -th point in this order is 。Then repeat the operation: let be the starting point and be the ending point, reorder in the same way, and compute the index of the new ending point。This process repeats in a loop。
In the figure below, initially 。Sort all points except in order, and the result is ,so the next ending point should be ,and the starting point is 。

Now 。Continue sorting by the rules. As in the lower-left figure, the result is 。So the next ending point is ,and the starting point is 。

Now 。Continue sorting by the rules. As in the upper-right figure, the result is 。So the next ending point is ,and the starting point is 。Now we return to the initial situation and enter a cycle。
Problem Description
We paint each of the points with one of three colors。The color of point is determined as follows:
- If there exists a point such that, choosing point as the starting point and point as the ending point, in the process above point will become the starting point infinitely many times, then paint point green。
- If point is not painted green and there exists a point such that, choosing point as the starting point and point as the ending point, in the process above point can still become the starting point at least once, then paint point blue。
- If point is neither green nor blue, then paint point red。
For each point, determine which color it should be painted。
Input Format
The first line contains two integers and 。
The next lines each contain two integers and 。It is guaranteed that no two points coincide。
Output Format
Output one line containing characters。The -th character of the string indicates the color of the -th point。
Green points are denoted by the letter G,blue points by B,and red points by R。
6 4
-1 -1
1 -2
4 -2
2 -4
2 3
-4 -5
GGBBRG
2 1
1 1
2 2
GG
Hint
Explanation for sample :
In the example given above, we already know that form a cycle. These three points will definitely be visited infinitely many times, so they should be painted green。
When the starting point is , we can take the ending point as 。After sorting, is exactly the fourth point, so returns to being a starting point again, as shown below. Therefore it should be painted blue。

When the starting point is , we can choose as the ending point. After sorting, is exactly the fourth point. Therefore can be painted blue。When is the starting point, it is easy to see that it can be painted neither green nor blue, so it should be painted red。
This problem uses bundled testdata。
| Subtask | Score | Special Properties |
|---|---|---|
| ,all points are collinear | ||
| all points are collinear | ||
| ,there are no blue points | ||
| ,there are no blue points | ||
| ,all points form a strictly convex -gon, and are given in counterclockwise order | ||
| none |
Constraints for all data: $2 \le n \le 1 000, 1 \le t \le n−1, −10^9 \le x_i, y_i \le 10^9$。
Translated by ChatGPT 5