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.
And Exp2 is valid.
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); } if (!(alice >= 0 && alice <= 11 && bob >= 0 && bob <= 11)) { cout << "error " << i; exit(0); } if (!(alice >= prevAlice && bob >= prevBob)) { cout << "error " << i; exit(0); } if ((prevBob == 11 || prevAlice == 11) && !(bob == prevBob && alice == prevAlice) || alice == 11 && bob == 11) { cout << "error " << i; exit(0); } prevBob = bob; prevAlice = alice; } cout << "ok"; return 0; }
|