Code for USACO practice problems
cpp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
752 B

using namespace std;
#include <cstdio>
#include <iostream>
int main() {
freopen("shell.in", "r", stdin);
freopen("shell.out", "w", stdout);
int n;
cin >> n;
int score = 0;
int a_values[n];
int b_values[n];
int g_values[n];
for (int i = 0; i < n; i++) {
cin >> a_values[i] >> b_values[i] >> g_values[i];
}
int shell_num;
shell_num = 0;
for (int i = 0; i < 3; i++) {
shell_num = i + 1;
for (int j = 0; j < n; j++) {
int a, b, g;
a = a_values[i];
b = b_values[i];
g = g_values[i];
if (a == shell_num) {
shell_num = b;
} else if (b == shell_num) {
shell_num = a;
}
if (g == shell_num) {
score++;
}
}
}
cout << score << endl;
}