blob: 65e76b6782adf225ff4f2c274e30e19059bfc5fe (
plain)
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
|
#include <cstdio>
using namespace std;
int
scoreFor(int their, int mine)
{
int outcome = (mine - their + 4) % 3; /* 0 loss, 1 draw, 2 win */
return outcome * 3 + mine + 1;
}
int
main()
{
char move, res;
long total1 = 0, total2 = 0;
while (scanf("%c %c ", &move, &res) == 2) {
move -= 'A';
res -= 'X';
if (!(0 <= move && move < 3)) throw "bad input";
if (!(0 <= res && res < 3)) throw "bad input";
int mine = (move + res - 1 + 3) % 3;
total1 += scoreFor(move, res);
total2 += scoreFor(move, mine);
}
printf("%ld\n", total1);
printf("%ld\n", total2);
}
|