forked from RiviereGregory/CodinGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Don_t_Panic_Level1.txt
82 lines (80 loc) · 3.78 KB
/
Don_t_Panic_Level1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
in.nextLine();
int etageBlock[] = new int[nbFloors];
for (int i = 0; i < nbFloors; i++) {
etageBlock[i] = 0;
}
System.err.println(nbFloors);
System.err.println(width);
System.err.println(nbRounds);
System.err.println(exitFloor);
System.err.println(exitPos);
System.err.println(nbTotalClones);
System.err.println(nbAdditionalElevators);
System.err.println(nbElevators);
int elevatorPos[] = new int[nbElevators];
for (int i = 0; i < nbElevators; i++) {
int elevatorFloor = in.nextInt(); // floor on which this elevator is found
elevatorPos[elevatorFloor] = in.nextInt(); // position of the elevator on its floor
in.nextLine();
System.err.println(elevatorFloor);
System.err.println(elevatorPos[elevatorFloor]);
}
// game loop
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
in.nextLine();
System.err.println("cloneFloor " +cloneFloor);
System.err.println("clonePos " +clonePos);
System.err.println("direction " +direction);
System.err.println("exitFloor " +exitFloor);
// Write an action using System.out.println()
// To debug: System.err.println("Debug messages...");
if(cloneFloor == -1){
System.out.println("WAIT"); // action: WAIT or BLOCK
}else if(exitFloor == cloneFloor){
System.err.println("EXIT etage");
if (etageBlock[cloneFloor] ==0 && clonePos > exitPos && "RIGHT".equalsIgnoreCase(direction)){
System.out.println("BLOCK");
etageBlock[cloneFloor] = 1;
}else if (etageBlock[cloneFloor] ==0 && clonePos < exitPos && "LEFT".equalsIgnoreCase(direction)){
System.out.println("BLOCK");
etageBlock[cloneFloor] = 1;
}else {
System.out.println("WAIT"); // action: WAIT or BLOCK
}
}else {
System.err.println("etage FLOOR");
System.err.println("elevatorPos " +elevatorPos[cloneFloor]);
if (etageBlock[cloneFloor] ==0 && elevatorPos[cloneFloor] < clonePos && "RIGHT".equalsIgnoreCase(direction)){
System.out.println("BLOCK");
etageBlock[cloneFloor] = 1;
}else if (etageBlock[cloneFloor] ==0 && elevatorPos[cloneFloor] > clonePos && "LEFT".equalsIgnoreCase(direction)){
System.out.println("BLOCK");
etageBlock[cloneFloor] = 1;
}else {
System.out.println("WAIT"); // action: WAIT or BLOCK
}
}
}
}
}