编程介的小学生 2017-09-01 15:38 采纳率: 20.5%
浏览 760
已采纳

Rocket Mania

Rocket Mania is one of my favourite games of Fantasy Games series. In the game, there are matches on the left hand side, and rockets on the right hand side. In between, there are different sorts of fuse blocks (See Figure A). These fuses can be rotated 0, 90, 180 or 270 degrees. To launch a rocket, you must form an unbroken path of fuses from the match to the rocket. When a fuse is complete, all rockets linked to a match will launch (See Figure B).

Your task is, given an initial situation, rotate some fuse blocks to make as many rockets launch as possible by firing one specified match.

Figure A Figure B Fuse Pipes
Input

Input contains multiple test cases. Each test case starts with a number X (1 <= X <= 9), which specifies the position of the match you can fire. Then followed by 9 lines, each line consists of 6 characters. The characters may be '.', '-', 'L', 'T' or '+', which specify an empty block or a corresponding type of fuse block.

Output

There is one line for each test case, which is the maximum number of rockets you can make launch by firing the match on the X'th row. If no rockets can launch, just output 0.

Sample Input

1
LLLLLL
LLLLLL
LLLLLL
LLLLLL
LLLLLL
LLLLLL
LLLLLL
LLLLLL
LLLLLL
3
......
.L----
-+----
.-....
.T---L
.L----
......
......
......
5
-L-L-L
-TL--T
-L-T-L
--+---
---T--
-TL---
---LT-
---T-T
-TL-T-
1
TTTTTT
TTTTTT
TTTTTT
TTTTTT
TTTTTT
TTTTTT
TTTTTT
TTTTTT
TTTTTT
Sample Output

1
3
4
9

  • 写回答

1条回答

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

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛