提交时间:2023-08-12 11:07:05

运行 ID: 27511

#include <bits/stdc++.h> using namespace std; int a[105],b[105],c[105],g[5],x,maxn; int main() { int n; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i]; for(int i=1;i<=3;i++) { x=0; g[i]=1; for(int j=1;j<=n;j++) { swap(g[a[j]],g[b[j]]); if(g[c[j]]==1) x++; } maxn=max(maxn,x); g[i]=0; } cout<<maxn; return 0; }