結果
問題 | No.1717 Levi-Civita Triangle |
ユーザー |
![]() |
提出日時 | 2021-10-22 22:43:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 1,302 bytes |
コンパイル時間 | 2,473 ms |
コンパイル使用メモリ | 194,728 KB |
最終ジャッジ日時 | 2025-01-25 04:02:11 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int f(int x,int y,int z){ if(x==0 && y==1 && z==2) return 1; if(x==1 && y==2 && z==0) return 1; if(x==2 && y==0 && z==1) return 1; if(x==2 && y==1 && z==0) return 2; if(x==1 && y==0 && z==2) return 2; if(x==0 && y==2 && z==1) return 2; return 0; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n; cin>>n; vector<int> A(2*n+1); rep(i,2*n+1) cin>>A[i]; if(n==1){ cout<<f(A[0],A[1],A[2])<<endl; return 0; } vector<int> B(2*n-1); rep(i,2*n-1){ if(f(A[i],A[i+1],A[i+2])==1) B[i]=1; else if(f(A[i],A[i+1],A[i+2])==2) B[i]=2; } bool b=true; rep(i,2*n-1){ if(i%4==0 && B[i]!=1) b=false; if(i%4==1 && B[i]!=0) b=false; if(i%4==2 && B[i]!=2) b=false; if(i%4==3 && B[i]!=0) b=false; } if(b){ if(n%2==0) cout<<2<<endl; else cout<<1<<endl; return 0; } b=true; rep(i,2*n-1){ if(i%4==0 && B[i]!=2) b=false; if(i%4==1 && B[i]!=0) b=false; if(i%4==2 && B[i]!=1) b=false; if(i%4==3 && B[i]!=0) b=false; } if(b){ if(n%2==0) cout<<1<<endl; else cout<<2<<endl; return 0; } cout<<0<<endl; return 0; }