0%

ANZAC CONTEST 4

A

Note:

You cannot focus on who wins the game. You should just follow the description in the problem “X is the score of the player who serves”.

So 1-0 is Bob serve. Then Bob’s score is 1.

1
2
3
4
Exp1:
2
0-0
1-0

And Exp2 is valid.

1
2
3
4
5
Exp2:
3
0-0
1-10
1-11
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
#include <iostream>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int currRound = 0;
int prevAlice = 0, prevBob = 0;
for (int i = 1; i <= n; i++) {
int alice, bob;
scanf("%d-%d", &alice, &bob);
currRound = alice + bob;
if (currRound % 4 == 1 || currRound % 4 == 2) {
swap(alice, bob);
}
//their score must in [0,11]
if (!(alice >= 0 && alice <= 11 && bob >= 0 && bob <= 11)) {
cout << "error " << i;
exit(0);
}
//during the game, alice must >= prev alice and bob must >= prev bob
if (!(alice >= prevAlice && bob >= prevBob)) {
cout << "error " << i;
exit(0);
}
//when game is over, their scores cannot be changed
if ((prevBob == 11 || prevAlice == 11) && !(bob == prevBob && alice == prevAlice)
// special condition check
|| alice == 11 && bob == 11) {
cout << "error " << i;
exit(0);
}
//set prev as curr
prevBob = bob;
prevAlice = alice;
}
cout << "ok";
return 0;
}