编程介的小学生 2017-05-24 12:45 采纳率: 20.5%
浏览 741
已采纳

Everyone is No.1

Problem Description
Everyone is No.1------ As long as there is belief in my heart, I will hold on until the last moment. Real hero, spirit never die!

See Figure 1, Teddy was in the left-up point, a ‘E’ represents a hole. Now, Teddy want to fill in all the hole. He has a special soil gun. When he shot, it can spread right or down at any time and fill the hole when it get through it, every shot must stop at the right-down point. See figure 2, Teddy should shot three times, but the more optimal solution was in the figure 3.

Figure 1

Figure 2 Figure 3

Your task is to create a program that will determine the minimum number shots needed to fill all the hole, if you can’t have any solution about it, don’t fell sorry. Because Everyone is No.1, you can solve other problems first , then return to this problem, you will see it can be so easy.

Input
The input consists of one or more field maps. A field map consists of two parts:
Firstly, two integers n, m ( 1 <= n, m <= 24)
Secondly, a nXm matrix represent the map.

‘E’ represent the empty hole.
‘.’ represent the soil.

Output
The output will consist of a single line for each field map containing the minimum number of shot needed to fill in all the empty hole.

Sample Input
6 7
.E.E...
...E.E.
.......
...E..E
.......
.....E.

2 2
EE
EE

Sample Output
2
2

  • 写回答

1条回答 默认 最新

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

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程