F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Everyone is No.1

Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 128    Accepted Submission(s): 36


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
 

Author
WhereIsHeroFrom
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-20 16:26:25, Gzip enabled