## ECOO '13 R2 P1 - Upsetris

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

The game of Upsetris is played just like the classic game of Tetris, but with a twist. Just like in Tetris, puzzle pieces, each made of four square bricks, fall from above and the user has to decide where they will land to try and make full rows of blocks. The game ends when the pile reaches the top of the screen.

In the game shown above, a straight vertical piece is falling. If the user drops it in the left most column (picture ), she will make the bottom four rows full (picture ), and the full rows will disappear allowing the pile to move down (picture ).

If the player makes bad decisions about where to put pieces, they can end up with boards with "holes" in them as shown at above-right. These holes will eventually cost them the game.

In Upsetris, the "twist" (pun intended) is that the user has a one-time-only chance to "upset" the board by rotating it degrees. When this happens, all the individual bricks separate and fall to the floor. This eliminates the holes and sometimes makes new rows.

Here's an example of the "upset" process in action:

 | | | | | | | | | O OOO O| |O O OOOO | | O O OO O| | OO OOOOO | | OOOOO| |OO OOOOO O| |==========| |==========| |O OOOOO OO| |OOOOO | | OOOOO OO | |O OO O O | | OOOO O O| |O OOO O | | | | | | | | | | | |O OOOOO OO| |OOOOO | | OOOOO OO | |O OO O O | | OOOO O O| |O OOO O | | | | | | | |==========| | | | | | | | | | OO | | OOO | |O OOO | |OOOOOO OO | |OOOOOO OOO| |OOOOOOOOOO| |==========| | | | | | | | | | | | OO | | OOO | |O OOO | |OOOOOO OO | |OOOOOO OOO| |==========| ~1~ ~2~ ~3~ ~4~ ~5~

In the example above, the bricks are represented by capital O's and the floor is a row of equal signs. The original board is rotated degrees , then the floor of the board is moved to the bottom , then the pieces all settle to the new floor making a single complete row which gets removed .

The input contains five different Upsetris boards, each with from to rows (not including the "floor") and from to columns (not including the walls). You must simulate the "upset" operation and show the final result for each board. You must show the complete board in your output, including the "floor" row. During judging, you will be allowed to scroll the output screen horizontally or vertically if necessary. The output must be in a fixed-width font (e.g. Courier).

If you are unable to configure your IDE to use a fixed width font, you may copy and paste the output of your program into a text editor that uses a fixed-width font during judging. Note that all the boards in the sample input are the same size and have the same number of rows as columns, but this might not be true of the data sets you will be judged on. The side characters for the board | are ASCII code .

#### Sample Input

|          |
|          |
|O         |
|O OO  O O |
|    O O   |
| O   O OO |
|  O     OO|
|O O       |
|   O  O O |
|O      O  |
|==========|
|          |
|          |
|          |
|    O     |
|   O  OO O|
|   O     O|
|    O  O  |
|       OO |
|O         |
|   O     O|
|==========|
|          |
|          |
|          |
|          |
| O   OOO O|
|O O  OOOO |
|  O O OO O|
| OO OOOOO |
|     OOOOO|
|OO OOOOO O|
|==========|
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
| O     O  |
|     O   O|
|==========|
|          |
|          |
|          |
|          |
|OO OO OOOO|
| O OOOOOOO|
|O OOOO OOO|
| OOOOOOOO |
|OOOO O O  |
|O  OOO OOO|
|==========|

#### Sample Output

|          |
|          |
|          |
|          |
|          |
|          |
|          |
| O       O|
| O O   O O|
| OOO  OO O|
|==========|
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|O O   O   |
|O O  OO   |
|OOOO OO  O|
|==========|
|          |
|          |
|          |
|          |
|          |
|  OO      |
|  OOO     |
|O OOO     |
|OOOOOO OO |
|OOOOOO OOO|
|==========|
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|O O O   O |
|==========|
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|  O   O   |
| OO OOO   |
|OOO OOO OO|
|==========|

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org