Guest User

Untitled

a guest
Nov 13th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. /**
  3. * Auto-generated code below aims at helping you parse
  4. * the standard input according to the problem statement.
  5. **/
  6.  
  7. fscanf(STDIN, "%d %d %d %d %d %d %d %d",
  8. $nbFloors, // number of floors
  9. $width, // width of the area
  10. $nbRounds, // maximum number of rounds
  11. $exitFloor, // floor on which the exit is found
  12. $exitPos, // position of the exit on its floor
  13. $nbTotalClones, // number of generated clones
  14. $nbAdditionalElevators, // ignore (always zero)
  15. $nbElevators // number of elevators
  16. );
  17.  
  18. $elevatorsPos = array();
  19.  
  20. for ($i = 0; $i < $nbElevators; $i++) {
  21. fscanf(STDIN, "%d %d",
  22. $elevatorFloor, // floor on which this elevator is found
  23. $elevatorPos // position of the elevator on its floor
  24. );
  25.  
  26. $elevatorsPos[$elevatorFloor] = $elevatorPos;
  27. }
  28.  
  29. $elevatorsPos[$exitFloor] = $exitPos;
  30.  
  31. // game loop
  32. while (TRUE) {
  33. fscanf(STDIN, "%d %d %s",
  34. $cloneFloor, // floor of the leading clone
  35. $clonePos, // position of the leading clone on its floor
  36. $direction // direction of the leading clone: LEFT or RIGHT
  37. );
  38.  
  39. // Write an action using echo(). DON'T FORGET THE TRAILING \n
  40. // To debug (equivalent to var_dump): error_log(var_export($var, true));
  41.  
  42. if (
  43. // isset($elevatorsPost[$cloneFloor]) && (
  44. ($clonePos < $elevatorsPos[$cloneFloor] && $direction === 'LEFT')
  45. || ($clonePos > $elevatorsPos[$cloneFloor] && $direction === 'RIGHT')
  46. // )
  47. ) {
  48. echo "BLOCK\n";
  49. } else {
  50. echo "WAIT\n";
  51. }
  52. }
Add Comment
Please, Sign In to add comment