#P3851. [TJOI2007] 脱险
[TJOI2007] 脱险
Description
The cave map is represented by an character matrix:
.means an empty cell with no explorer at the beginning; an empty cell can hold any number of explorers.Pmeans an empty cell with an explorer at the beginning. We assume that initially all explorers are in distinct cells, and no explorer is initially on an exit cell.*means an obstacle; explorers cannot pass through cells occupied by obstacles.O(capital letter O) means an exit. The input guarantees that every exit lies on the boundary of the map, i.e.,Ocan appear only in row , row , column , or column .
Additionally, the input guarantees that the entire map is enclosed by boundary and exits, i.e., in row , row , column , and column , only * or O may appear.
Input Format
The first line contains two integers and separated by a space, denoting the size of the map. The second line contains the integer , the time until the cave collapses. The next lines each contain characters, describing a cave map.
Output Format
Output one line containing a single integer, the maximum number of explorers that can escape within time units.
5 5
4
*****
*P..*
O**.O
*P..*
*****
1
Hint
The cave has two exits, but only the right exit is reachable. Although in time units both people can reach the cell to the left of the exit, because at most one person can pass through the exit per time unit, only one person can escape within time units. Both can escape in time units.
- For of the testdata, the numbers of explorers and exits are both at most .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号