#include #include #include using namespace std; vector> parse() { vector> input; for (string line; getline(cin, line);) { if (line.size() < 3 || line[1] != ' ') throw "parse"; unsigned oppo = line[0] - 'A'; unsigned user = line[2] - 'X'; if (oppo >= 3 || user >= 3) throw "parse"; input.push_back({oppo, user}); } return input; } unsigned p1(vector> &input) { unsigned score = 0; for (auto i : input) { unsigned shape = i[1]; unsigned outcome = (i[1] - i[0] + 4) % 3; score += shape + 1 + outcome * 3; } return score; } unsigned p2(vector> &input) { unsigned score = 0; for (auto i : input) { unsigned shape = (i[1] + i[0] + 2) % 3; unsigned outcome = i[1]; score += shape + 1 + outcome * 3; } return score; } int main() { auto input = parse(); cout << p1(input) << endl; cout << p2(input) << endl; }