编程介的小学生 2017-08-27 03:46 采纳率: 20.5%
浏览 736
已采纳

Gem Squares

Problem Description
You are given a board with 8×8 squares. In each square, there can be either a colored gem or no gem at all. Gems with different colors are represented by different integers. It is guaranteed that there are no more than two consecutive gems with the same color either in a row or in a column, and that there is not any gem above a blank square.

........
........
........
........
........
..43366.
..121556
44212335

For two neighboring squares, you can exchange the gems.

........
........
........
........
........
..43366.
..111556
44222335

If there are more than two consecutive gems with the same color in a row or in a column after exchange, these gems will be taken away simultaneously. Note that a gem could be counted both in its row and in its column; refer to the sample test cases for details.

........
........
........
........
........
..43366.
.....556
44...335

If there is no gem under a gem, the gem will fall to the square below.

........
........
........
........
........
.....66.
.....556
44433335

After all gems have fallen down to the lowest place, the procedure will be repeated. If there are more than two gems with the same color in a row or in a column, these gems will be taken away simultaneously. Then some gems will fall to the squares below, if there are no gems under those gems.

........
........
........
........
........
.....66.
.....556
.......5

........
........
........
........
........
........
.....666
.....555

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

The procedure will be repeated until there is no gem that can be taken away.

Given a board with 8*8 squares, you task is to determine whether all gems can be taken away by a single exchange or not.

  • 写回答

1条回答 默认 最新

  • devmiao 2017-08-27 15:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn