提交时间:2023-08-12 11:18:04

运行 ID: 27517

#include<bits/stdc++.h> using namespace std; bool cmp(int x,int y) { return x>y; } int s[3],t[3]; int a[105],b[105],g[105]; int main() { int n; cin>>n; int w=0; for(int i=0;i<n;i++) { cin>>a[i]>>b[i]>>g[i]; } for(int j=0;j<3;j++) { int s[3]={0,0,0}; s[j]=1; for(int i=0;i<n;i++) { w=s[a[i]]; s[a[i]]=s[b[i]]; s[b[i]]=w; if(s[g[i]]==1) { t[j]++; } } } sort(t,t+3,cmp); for(int j=0;j<1;j++) { cout<<t[j]<<endl; } return 0; }