-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathJava.java
52 lines (43 loc) · 1.54 KB
/
Java.java
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
/****************************************/
/* */
/* CodinGame.com Solutions by pathosDev */
/* */
/* Puzzle: Guessing n Cheating */
/* Difficulty: Easy */
/* Date solved: 05.03.2019 */
/* */
/****************************************/
import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int R = Integer.parseInt(scanner.nextLine());
int start = 1, end = 100;
for (int i = 0; i < R; i++)
{
//Read conversations.
String[] guess = scanner.nextLine().split(" ");
int bob = Integer.parseInt(guess[0]);
String alice = guess[1] + " " + guess[2];
//Adjust range.
if (alice.equals("too low"))
{
start = Math.max(start, bob + 1);
}
else if (alice.equals("too high"))
{
end = Math.min(end, bob - 1);
}
//Check if alice cheated.
if (end < start || alice.equals("right on") && !(start <= bob && bob <= end))
{
System.out.println("Alice cheated in round " + (i + 1));
System.exit(0);
}
}
//Alice didn't cheat.
System.out.println("No evidence of cheating");
}
}