#P8154. 「PMOI-5」棋盘
「PMOI-5」棋盘
Problem Description
Given an infinite chessboard (which can be viewed as a 2D Cartesian coordinate system) and white pieces and black pieces, you need to place them on integer lattice points of the board without overlap, such that there exist exactly straight lines satisfying:
-
Each line passes through and only passes through a total of 4 pieces (black and white together).
-
Along the line in order, it passes through black, white, white, black pieces.
Output any valid construction.
Input Format
The input contains only one line: as described in the statement.
Output Format
If it is impossible to construct a solution, output NO.
Otherwise output lines: the first line outputs YES. Lines each contain two integers, the coordinates of a white piece. Lines each contain two integers, the coordinates of a black piece.
You must ensure that .
1
NO
7
YES
2 4
2 6
4 6
5 4
6 4
6 2
4 2
0 6
2 8
6 6
8 2
6 0
3 0
2 2
Hint
[Sample Explanation]
Explanation for Sample 2: (The output lists points in order (points are white pieces, points are black pieces), and the lines are shown in the figure).

[Constraints]
This problem uses bundled testdata.
- Subtask 1 (10 pts): .
- Subtask 2 (20 pts): .
- Subtask 3 (30 pts): .
- Subtask 4 (40 pts): no special restrictions.
For of the testdata, .
Usage: after compiling to checker.exe, in the same directory run on the command line:
checker.exe chessboard.in chessboard.out chessboard.ans
You also need to use it together with testlib.h. testlib download link.
If you find the SPJ is broken, please contact the problem setter.
Translated by ChatGPT 5