2018 KAIST RUN Spring Contest |
---|
Finished |
PuyoPuyo is a 2 player battle game. Each player plays by placing Puyo to grid. The detailed game rule is as follows:
Sonic Team™ requested your help to make PPAP (Puyo Puyo Algorithm for Printing). This will not be used in game software but will be used in special ceremonies.
You are given an R × C grid. Each cell of the grid contains a Puyo of a certain color or is empty. You should start from an empty grid and drop Puyo pairs to derive the given grid.
Fortunately, you can choose which color and place to drop.
First line contains three space-separated integers R, C and K. (R = C = 4 or R = C = 20, 3 ≤ K ≤ 6)
Next R lines contain the final grid. Each line contains C number of space-separated integers. Each color is represented by an integer 1 through K. 0 means an empty cell.
A given final grid can be made by no more than 250 Puyo pair drops.
In the first line, you have to print the number of Puyo pairs D. (D ≤ 250)
In following D lines, print four space-separated integers in each line.
4 4 3
0 0 0 0
0 0 0 0
0 0 0 0
0 1 0 1
5
0 2 1 2
1 4 1 2
0 2 2 3
1 3 3 3
1 3 2 3
In this example, Puyos are dropped like following :
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0
0 0 0 0 -> 0 0 0 0 -> 0 0 0 0 -> 0 0 3 0 -> 0 0 3 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 3 0
0 0 0 0 0 0 0 1 0 2 3 1 0 2 3 1 0 2 3 1
0 1 2 0 0 1 2 2 0 1 2 2 0 1 2 2 0 1 2 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-> 0 0 0 0 -> 0 0 0 0 -> 0 0 0 0 -> 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 2 0 1 0 2 2 1 0 0 0 1 0 0 0 0
0 1 2 2 0 1 2 2 0 1 0 0 0 1 0 1
Name |
---|