Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- fscanf(STDIN, "%d %d %d %d %d %d %d %d",
- $nbFloors, // number of floors
- $width, // width of the area
- $nbRounds, // maximum number of rounds
- $exitFloor, // floor on which the exit is found
- $exitPos, // position of the exit on its floor
- $nbTotalClones, // number of generated clones
- $nbAdditionalElevators, // ignore (always zero)
- $nbElevators // number of elevators
- );
- $elevatorsPos = array();
- for ($i = 0; $i < $nbElevators; $i++) {
- fscanf(STDIN, "%d %d",
- $elevatorFloor, // floor on which this elevator is found
- $elevatorPos // position of the elevator on its floor
- );
- $elevatorsPos[$elevatorFloor] = $elevatorPos;
- }
- $elevatorsPos[$exitFloor] = $exitPos;
- // game loop
- while (TRUE) {
- fscanf(STDIN, "%d %d %s",
- $cloneFloor, // floor of the leading clone
- $clonePos, // position of the leading clone on its floor
- $direction // direction of the leading clone: LEFT or RIGHT
- );
- // Write an action using echo(). DON'T FORGET THE TRAILING \n
- // To debug (equivalent to var_dump): error_log(var_export($var, true));
- if (
- // isset($elevatorsPost[$cloneFloor]) && (
- ($clonePos < $elevatorsPos[$cloneFloor] && $direction === 'LEFT')
- || ($clonePos > $elevatorsPos[$cloneFloor] && $direction === 'RIGHT')
- // )
- ) {
- echo "BLOCK\n";
- } else {
- echo "WAIT\n";
- }
- }
Add Comment
Please, Sign In to add comment