Submission #640893

#TimeUsernameProblemLanguageResultExecution timeMemory
640893andreast12Kocka (COCI18_kocka)C++17
0 / 70
31 ms3692 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb push_back const int mod=998244353, maxn=1e5+5; int n, a[10][maxn], ki, ka, atas, bwh, pmin[maxn], pmax[maxn], cnt[maxn], paski[maxn]; bool ans=true; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i=1; i<=4; i++) { for(int j=1; j<=n; j++) cin >> a[i][j]; } for(int i=0; i<=n; i++) pmin[i]=mod, pmax[i]=-1; for(int i=1; i<=n; i++) { ki=a[1][i], ka=a[2][i]; if((ki==-1)^(ka==-1)) ans=false; if((ki==-1)&&(ka==-1)) continue; if(ki+ka+1<=n) { ki++, ka=n-ka; pmin[ki]=min(pmin[ki], i); pmin[ka+1]=min(pmin[ka+1], mod); pmax[ki]=max(pmax[ki], i); pmax[ka+1]=max(pmax[ka+1], -1); cnt[ki]++, cnt[ka+1]--, paski[ki]++; } else ans=false; } for(int i=1; i<=n; i++) { cnt[i]+=cnt[i-1]; if(cnt[i]==0||cnt[i]==paski[i]) continue; pmin[i]=min(pmin[i], pmin[i-1]); pmax[i]=max(pmax[i], pmax[i-1]); } for(int i=1; i<=n; i++) { atas=a[3][i], bwh=a[4][i]; if((atas==-1)^(bwh==-1)) ans=false; if(atas==-1&&bwh==-1) { if(!(pmin[i]==mod&&pmax[i]==-1)) ans=false; else continue; } if(!((atas==pmin[i]-1)&&(n-pmax[i]==bwh))) ans=false; } cout << ((ans)?"DA":"NE") << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...