Advertisement
AdamTheGreat

Untitled

Sep 2nd, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Time Limit:0.2s
  2. Memory Limit:32M
  3. Description:
  4. 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.
  5. Input:
  6. The first line contains two integers n,m.
  7. The next are n lines. Each line has m characters represent the map. 1<=n,m<=200
  8. '@' is your position
  9. '#' means an obstacle
  10. '.' means there is a way you can go
  11. 'F' means KFC
  12. '&' means the position of your friend.
  13. '.', 'F', '@' and '&': you can go through all these positions.
  14. Output
  15. 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".
  16.  
  17. Sample Input1
  18. 4 4
  19. @.#F
  20. ....
  21. .#..
  22. F..&
  23.  
  24. ​Sample Output1
  25. 6
  26.  
  27. Sample Input2
  28. 4 4
  29. &.#F
  30. ....
  31. .#..
  32. F#.@
  33.  
  34. ​Sample Output2
  35. 8
  36. Hint
  37. Meeting Cancelled means that there is no KFC site satisfying the conditions.
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement