#P9567. [SDCPC 2023] Puzzle: Sashigane
[SDCPC 2023] Puzzle: Sashigane
题目描述
Given a grid with rows and columns, there is exactly one black cell in the grid and all other cells are white. Let be the cell on the -th row and the -th column, this black cell is located at .
You need to cover all white cells with some L-shapes, so that each white cell is covered by exactly one L-shape and the only black cell is not covered by any L-shape. L-shapes must not exceed the boundary of the grid.
More formally, an L-shape in the grid is uniquely determined by four integers , where determines the turning point of the L-shape, and and determine the direction and lengths of the two arms of the L-shape. The four integers must satisfy , , , , .
- If , then all cells satisfying belong to this L-shape; Otherwise if , all cells satisfying belong to this L-shape.
- If , then all cells satisfying belong to this L-shape; Otherwise if , all cells satisfying belong to this L-shape.
The following image illustrates some L-shapes.
输入格式
There is only one test case in each test file.
The first line contains three integers , and (, ) indicating the size of the grid and the position of the black cell.
输出格式
If a valid answer exists first output Yes
in the first line, then in the second line output an integer () indicating the number of L-shapes to cover white cells. Then output lines where the -th line contains four integers , , , separated by a space indicating that the -th L-shape is uniquely determined by . If there are multiple valid answers you can print any of them.
If there is no valid answer, just output No
in one line.
5 3 4
Yes
6
5 1 -1 3
1 2 1 3
3 1 -2 1
4 3 -1 -1
4 5 1 -1
2 5 1 -2
1 1 1
Yes
0
提示
We illustrate the first sample test case as follows.