编程介的小学生 2017-08-20 16:21 采纳率: 20.5%
浏览 877
已采纳

Diamond

Diamond mine is a mini-game which is played on an 8 * 8 board as you can see below.

The board is filled with different colors of diamonds. The player can make one move at a time. A move is legal if it swaps two adjacent diamonds(not diagonally) and after that, there are three or more adjacent diamonds in a row or column with the same color. Those diamonds will be taken away and new diamonds will be put in their positions. The game continues until no legal moves exist.

Given the board description. You are going to determine whether a move is legal.

Input

The input contains several cases. Each case has exactly 9 lines. The first 8 lines each contains a string of 8 characters. The characters are 'R'(Red), 'O'(Orange), 'G'(Green), 'P'(Purple), 'W'(White), 'Y'(Yellow) or 'B'(Blue). All characters are uppercase. No 3 diamonds of the same color are initially in adjacent positions in a row or column. The last line has 4 integers in the form " row1 column1 row2 column2" describing the postions of the 2 diamonds that the player wants to swap. Rows are marked 1 to 8 increasingly from top to bottom while columns from left to right. Input is terminated by EOF.

Output

For each case, output "Ok!" if the move is legal or "Illegal move!" if it is not.

Sample Input

PBPOWBGW
RRPRYWWP
YGBYYGPP
OWYGGRWB
GBBGBGGR
GBWPPORG
PPGORWOG
WYWGYWBY
4 3 3 3
PBPOWBGW
RRPRYWWP
YGBYYGPP
OWYGGRWB
GBBGBGGR
GBWPPORG
PPGORWOG
WYWGYWBY
5 5 6 5

Sample Output

Ok!
Illegal move!

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-01 15:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘