시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 43 | 27 | 13 | 92.857% |
Mr. JOI loves a game called “JOIRIS.” But he is not good at playing it. JOIRIS is played on a rectangular board, which is a grid of square cells. The width of the board is N, and the height of it is sufficiently large. The cell in the i-th column from left and the j-th row from below is denoted by (i, j). During the game, the state of each cell is one of the following: there is a block on it, or there is no block on it.
JOIRIS is played as follows.
The purpose of JOIRIS is to remove all blocks from the board by putting pieces no more than 10 000 times.
But, Mr. JOI does not know how to accomplish it because he is not good at playing this game. Your task is to determine whether it is possible to remove all blocks from the board by putting pieces no more than 10 000 times, and to find a way to accomplish it if it is possible.
Given the information on the initial state of the board of JOIRIS and the size of pieces, write a program which determines whether it is possible to remove all blocks from the board by putting pieces no more than 10 000 times, and to find a way to accomplish it if it is possible.
Read the following data from the standard input.
If it is impossible to remove all blocks from the board by putting pieces no more than 10 000 times, output the integer −1 in one line.
Otherwise, the output consists of X + 1 lines, where X is the number of operations to put pieces on the board.
All input data satisfy the following conditions.
There are no additional constraints.
4 2 1 0 1 2
4 2 2 1 1 2 3 1 2
This Sample Output corresponds to the following figure.
3 2 2 0 1
3 1 2 1 3 2 1
2 2 0 1
-1