Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. ### DWITE Online Computer Programming Contest, October 2007, Problem 5
  2.  
  3. A ~~common~~ problem is being chased through a maze by a hungry velociraptor. There is no time to think as to how one came to be in such a situation. A program is required to calculate the survival time of a human character.
  4.  
  5. The maze consists of hallways, and has no open areas. There are no loops in the maze - that is, there is always only one possible path between any two points. There is just one exit, one human, and one velociraptor present in the maze. The only possible chance of survival is to make it to the exit before the velociraptor does. The velociraptor will also run towards the exit, covering twice as much ground "per turn" as the human figure.
  6.  
  7. Note:*the velociraptor has no intelligence, but it knows its way to the exit. It will attack only when it occupies the same "square" as a human. In a case when the velociraptor is between a human and the exit, both will continue running until they meet at the exit location.*
  8.  
  9. The input will contain two lines with one integer value each, ~R, C~; ~0 \le R, C \le 10~, representing the number of *Rows* and *Columns* that make up the maze. Followed by ~R~ lines, showing the maze layout, where:
  10.  
  11. - `#` - wall
  12. - `.` - open path
  13. - `E` - exit
  14. - `H` - human
  15. - `V` - velociraptor
  16.  
  17. The output will contain a single line for the result.
  18.  
  19. In an event that the velociraptor catches up with the human on the way to the exit, output a single integer, representing the number of steps a human took before the event. The human has an advantage, this will always be at least one, even if the velociraptor is right behind (or ahead).
  20.  
  21. In an event that the velociraptor makes it to the exit first, it will wait there. It will "catch up" right after the human figure steps onto the exit square.
  22.  
  23. In an event that the human and the velociraptor make it to the exit at the same time, the human still gets caught. Output the number of steps.
  24.  
  25. If in a given turn the human finds himself at the exit square, but the velociraptor does not, output `escape`. Lower case, no quotations.
  26.  
  27.  
  28. ## Sample Input 1
  29.  
  30. 3
  31. 5
  32. #####
  33. V..HE
  34. #####
  35.  
  36. ## Sample Output 1
  37.  
  38. escape
  39.  
  40. ## Sample Input 2
  41.  
  42. 3
  43. 5
  44. #####
  45. H..EV
  46. #####
  47.  
  48. ## Sample Output 2
  49.  
  50. 3
  51.  
  52.  
  53. <span id="dwite-footer"><span style="float:right;font-size:0.85em;color:gray;margin-top:-6px"><a href="https://creativecommons.org/licenses/by-nc-sa/3.0/">Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)</a> Problem Resource: <a rel="nofollow" href="http://dwite.org/questions/velociraptor_maze.html" style="text-decoration:none;">DWITE</a></span>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement