blob: 0ab6017d09fe51d6ae88d11b81d0095a2d48d435 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include <cstdio>
using namespace std;
int
main()
{
char move, res;
long total = 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 outcome = (res - move + 4) % 3; /* 0 loss, 1 draw, 2 win */
long score = outcome * 3 + res + 1;
total += score;
}
printf("%ld\n", total);
}
|