Submit | All submissions | Best solutions | Back to list |
LCPC12B - Johnny plays with connect 4 |
"Connect Four is a two-player game in which the players first choose a color and then take turns dropping colored discs from the top into a seven-column, six-row grid. The pieces fall straight down, occupying the next available space within the column. The objective of the game is to connect four of one's own discs of the same color next to each other vertically, horizontally, or diagonally before his opponent." – Wikipedia.
Johnny plays with the connect-four board, Johnny has N discs and each disc has a number on it. Johnny drops these discs in the board columns. as Johnny was nervous he closed the top of the board and rotated it with different angles, when he rotate the board 90 degree, all pieces slide over their rows till they hit the board boundary or touch another piece. You will be given the board configuration and those rotation angles. And you should write a program that calculates the new discs’ positions.
Input Format
Input will start with T number of test cases. Followed by T test cases each test case starts with board dimensions R and C where R (1 < R < 100) is number of rows and C (1 < C < 100) is number of columns, and number of discs N (0 ≤ N ≤ R × C). Then N lines follow, each contains two integers: P specifying the column number (0 ≤ P < C) and Q specifying the disc number (0 ≤ Q ≤ 9). Then you will be given number of rotations L followed by L positive integers representing the rotation angles, all angles will be anti-clockwise in the main directions (90, 180, and 270) only.
Output Format
For each test case, output the result using the following format:
k (the test case number starting at 1) followed by a period (on a line by itself), then the final configuration of the board. Each row on a line by itself, and each cell is either a "." (without quotes) if the cell is an empty or a number representing a piece.
Sample
Input 4 2 3 2 0 5 2 9 0 2 3 2 0 5 2 9 1 90 2 3 2 0 5 2 9 1 180 2 3 2 0 5 2 9 2 90 90 Output 1. ... 5.9 2. .. .9 .5 3. ... 9.5 4. ... .95
Added by: | Gareev |
Date: | 2012-10-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | LCPC 2012 |
hide comments
2013-08-30 08:18:37 numerix
If you like that game you may want to solve problem FOUROW. |