열 높이가 주어진 보드에서 1xK 조각을 수직 또는 수평으로 놓아 가득 찬 행을 지우며, 10000번 이내에 모든 블록을 제거하는 방법을 찾거나 불가능하면 -1을 출력한다.
어려움9그리디시뮬레이션구현수학아직 제출이 없습니다시간 제한1초메모리 제한256 MBMr. 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.
A sequence of integers A1, A2, . . . , AN is given, which represents the initial state of the game.
In the beginning, in the i-th column (1 ≤ i ≤ N), there is a block on each of Ai cells from below, and there is no block on other cells. In other words, there is a block on each cell (i, j) with 1 ≤ j ≤ Aj only.
The player has 10 000 rectangular pieces. Each piece is a rectangle of 1 × K blocks. The player performs the following operations repeatedly.
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.
The first line of output contains the integer X.
The i-th line (1 ≤ i ≤ X) of the following X lines contains the information of the i-th piece to put on the board in the following format.
All input data satisfy the following conditions.