编程介的小学生 2017-08-20 16:21 采纳率: 20.3%
浏览 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
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路