시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 5 | 4 | 4 | 80.000% |
“Joining points” is a single-player game. To play it, choose two integers greater than two and call them g and r. Then draw four points at the vertices of a square making the top two points green and the bottom two points red. Draw green points and red points inside the square taking care that no three points, including the four initial ones, are in the same line. Continue until the total number of green points equals g and the total number of red points equals r.
After the board is drawn, start joining points. Any two points can be joined by a line segment as long as:
Two points u and v are said to be in the same component if it is possible to traverse from point u to point v using the line segments already drawn.
You win the game if you get all the green points in one component using exactly g-1 line segments, and all the red points in another component using exactly r-1 line segments. It can be proven that if the points are drawn as described above, then there is always a way to win the game.
You will be given a square board of size s with g green and r red points whose coordinates are represented by integer pairs (xi, yi). Green points are numbered from 1 to g with the top-left point at (0,s) being 1, the top-right at (s,s) being 2, and interior points ranging from 3 to g in arbitrary order. Red points are numbered from 1 to r with the bottom-left point at (0,0) being 1, the bottom-right at (s,0) being 2, and interior points ranging from 3 to r in arbitrary order.
The figure shows a sample game all the green points are joined into one component and all the red points are joined into another component.
You can see that no three points are in the same line, and that no two line segments intersect each other except at their endpoints.
Write a program that, given the coordinates of the g green points and the coordinates of the r red points, decides how to draw g - 1 green line segments and r - 1 red line segments so that all of the green points are in the same component, all of the red points are in another component, and no two line segments intersect each other.
Your output file must contain (g – 1) + (r – 1) lines, one for every line segment drawn to join points.
Each line must contain three space-separated entities: two integers and a character.The two integers represent the numbers of two points joined by that line segment. The character must be a g if the points are green and an r if the joined points are red.
The order in which you list the line segments does not matter; neither does the order of the endpoints of each line segment.
6 0 1000 1000 1000 203 601 449 212 620 837 708 537 8 0 0 1000 0 185 300 314 888 416 458 614 622 683 95 838 400
1 3 g 3 1 r 3 5 r 4 6 r 6 5 r 4 6 g 1 2 g 1 2 r 5 2 g 2 6 g 7 8 r 8 2 r