Created
August 11, 2017 17:00
-
-
Save anonymous/a08fbf99dd166ac0372ba20af2fc5aca to your computer and use it in GitHub Desktop.
Dont Panic Episode1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
import java.math.*; | |
/** | |
* Auto-generated code below aims at helping you parse | |
* the standard input according to the problem statement. | |
**/ | |
class Player { | |
public static void main(String args[]) { | |
Scanner in = new Scanner(System.in); | |
int nbFloors = in.nextInt(); // number of floors | |
int width = in.nextInt(); // width of the area | |
int nbRounds = in.nextInt(); // maximum number of rounds | |
int exitFloor = in.nextInt(); // floor on which the exit is found | |
int exitPos = in.nextInt(); // position of the exit on its floor | |
int nbTotalClones = in.nextInt(); // number of generated clones | |
int nbAdditionalElevators = in.nextInt(); // ignore (always zero) | |
int nbElevators = in.nextInt(); // number of elevators | |
int[]elevatorArray = new int[nbElevators+1]; //position of the elevator on its floor | |
for (int i = 0; i < nbElevators; i++) { | |
int elevatorFloor = in.nextInt(); // floor on which this elevator is found | |
int elevatorPos = in.nextInt(); // position of the elevator on its floor | |
elevatorArray[elevatorFloor] = elevatorPos; | |
} | |
elevatorArray[exitFloor]=exitPos; | |
// game loop | |
// To debug: System.err.println("Debug messages..."); | |
while (true) { | |
int cloneFloor = in.nextInt(); // floor of the leading clone | |
int clonePos = in.nextInt(); // position of the leading clone on its floor | |
String direction = in.next(); // direction of the leading clone: LEFT or RIGHT | |
if( clonePos >= 0 ){ | |
// if ( elevatorArray.length > 0 ) { | |
System.err.println("Leading CloneFloor: " + cloneFloor); | |
System.err.println("Leading ClonePos: " + clonePos); | |
System.err.println("cloneFloor: " + cloneFloor + ", clonePos: " + clonePos + ", elevatorPos: " + elevatorArray[cloneFloor]); | |
if( clonePos > elevatorArray[cloneFloor] && direction.equals( "RIGHT" ) ){ | |
System.err.println("Block shoud be activated (Clone shoud face to the right after he stops)"); | |
System.out.println("BLOCK"); | |
} | |
if( clonePos < elevatorArray[cloneFloor] && direction.equals( "LEFT" ) ){ | |
System.err.println("Block shoud be activated (Clone shoud face to the left after he stops)"); | |
System.out.println("BLOCK"); | |
} | |
} | |
System.out.println("WAIT"); // action: WAIT or BLOCK | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment