#P10172. 「OICon-02」Pick Stone
「OICon-02」Pick Stone
Problem Description
Little S has an chessboard. Initially, each cell has a stone. Each time, Little S may remove one stone such that the number of removed stones around it (4-neighborhood) is at most . Find the maximum number of stones Little S can remove, and construct one valid removing plan.
Input Format
One line with two positive integers , representing the board size.
Output Format
The first line contains one positive integer, the maximum number of stones that can be removed, .
Then output lines, each with integers between and . The number in each cell indicates at which step the stone in this cell is removed. If the stone in that cell is not removed, output .
2 2
3
1 2
3 -1
3 5
12
2 3 4 5 6
1 -1 12 -1 7
8 9 -1 11 10
Hint
Sample Explanation
For Sample , when removing , there are removed cells around it. When removing and , there is removed cell around each of them. Therefore, the construction satisfies the requirement.
It is easy to prove that there is no better answer.
Constraints
This problem uses bundled testdata.
| Special Property | ||
|---|---|---|
For of the testdata: , .
If you get the first part (the maximum number of stones that can be removed) correct but fail to construct correctly, you will get of the score. For each subtask, your score is the minimum score among all test points in that subtask. Note that you still need to output numbers as the construction plan in the required format. We recommend outputting all .
It is guaranteed that checker.cpp runs in no more than seconds with an output that meets the format requirements.
Translated by ChatGPT 5