编程介的小学生 2017-04-29 16:22 采纳率: 20.5%
浏览 989
已采纳

Brick Game

There's a game called Brick Game. In this game, the player controls a number of bricks on a 9*9 grid. In every step, the player has 3 choices. One is rotating the 9*9 grid clockwise; The second is rotating the 9*9 grid counter-clockwise; The third is dropping a pattern sized 1*3 bricks(you should treat them separately) down from the middle of the upest line. Each brick has a kind of color. After each step, the bricks that hang in the air will drop down until they touch other bricks or the bottom, then three or more adjacent bricks will be removed if they have the same color(here we call two bricks that share a common border "adjacent"). This process will go on until no brick can be removed. In this problem, you are asked to simulate the whole process. The 9*9 grid is empty at the beginning. A list of what the player has done will be given. You should output the final situation after all the operation by the player.

Input:

The input consists of several test cases. Each test case contains several lines. There's a operation in each line, which can be 'CW', 'CCW', 'DROP' as the description above. If the operation is 'DROP', it will be followed by a string contains exactly upper letters. In the string, each upper letter represents a kind of color. There're five kinds of color, R(red), G(green), B(blue), Y(yellow), W(white). The end for each test case is always a line contains 'END'.

Output:

The output of each test case contains a string of "FAIL" or a final situation with 9*9 grid. "FAIL" should be output if the drop operation fails during the process, i.e. there're bricks in the three middle of the upest line when the player want to drop a new pattern. Note that output the whole 9*9 grid and use a '.' represents the empty grid. Output a blank line after each test case.

Sample Input:

DROP RGB
CW
CCW
END

DROP RGB
DROP RGB
DROP RGB
END
Sample Output:

.........
.........
.........
.........
.........
.........
.........
.........
......RGB

.........
.........
.........
.........
.........
.........
.........
.........
.........

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题