aboutsummaryrefslogtreecommitdiff
path: root/shell.cpp
blob: 97b641dbe4a9c322e4dafb88a5bbbbb90c971607 (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
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;

int main() {
	ifstream cin("shell.in");
	ofstream cout("shell.out");

	int N;
	cin >> N;

	int a[101], b[101], g[101];
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i] >> g[i];
	}

	int ans = 0;

	for (int start : { 1, 2, 3 }) {
		int pos = start;
		int cnt = 0;
		for (int i = 0; i < N; ++i) {
			if (pos == a[i]) {
				pos = b[i];
			}
			else if (pos == b[i]) {
				pos = a[i];
			}

			if (pos == g[i]) {
				++cnt;
			}
		}

		ans = max(cnt, ans);
	}

	cout << ans;
}