编程介的小学生 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 请提供一个符合要求的网页链接。
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码