Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Time Limit:0.2s
- Memory Limit:32M
- Description:
- As the summer holiday drawing near, you and your friend plan to eat at a KFC. But on the map there are many KFC,so you should come up with a way to choose one. The way is: Calculate the trave distances from one KFC to your and your friend's home, if the sum of the distances is the least that KFC will be chosen.
- Input:
- The first line contains two integers n,m.
- The next are n lines. Each line has m characters represent the map. 1<=n,m<=200
- '@' is your position
- '#' means an obstacle
- '.' means there is a way you can go
- 'F' means KFC
- '&' means the position of your friend.
- '.', 'F', '@' and '&': you can go through all these positions.
- Output
- If you can find a way to get some KFC sites, output the least distance in which you guys will tavele from each one's home to that KFC. Other wise output "Meeting cancelled".
- Sample Input1
- 4 4
- @.#F
- ....
- .#..
- F..&
- Sample Output1
- 6
- Sample Input2
- 4 4
- &.#F
- ....
- .#..
- F#.@
- Sample Output2
- 8
- Hint
- Meeting Cancelled means that there is no KFC site satisfying the conditions.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement