Submission #750484

#TimeUsernameProblemLanguageResultExecution timeMemory
750484TrunktyKocka (COCI18_kocka)C++14
14 / 70
95 ms22588 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll int n; int l[100005],r[100005],u[100005],d[100005]; map<int,bool> mp[100005]; signed main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i=1;i<=n;i++){ cin >> l[i]; } for(int i=1;i<=n;i++){ cin >> r[i]; } for(int i=1;i<=n;i++){ cin >> u[i]; } for(int i=1;i<=n;i++){ cin >> d[i]; } for(int i=1;i<=n;i++){ if(l[i]==-1 and r[i]==-1){ continue; } else if(l[i]==-1 or r[i]==-1){ cout << "NE" << "\n"; return 0; } else if(l[i]+r[i]>=n){ cout << "NE" << "\n"; return 0; } } for(int i=1;i<=n;i++){ if(u[i]==-1 and d[i]==-1){ continue; } else if(u[i]==-1 or d[i]==-1){ cout << "NE" << "\n"; return 0; } else if(u[i]+d[i]>=n){ cout << "NE" << "\n"; return 0; } } for(int i=1;i<=n;i++){ if(u[i]!=-1){ mp[u[i]+1][i] = true; mp[n-d[i]][i] = true; } } for(int i=1;i<=n;i++){ if(l[i]==-1){ if(!mp[i].empty()){ cout << "NE" << "\n"; return 0; } } else{ if(mp[i].empty()){ cout << "NE" << "\n"; return 0; } int x = mp[i].begin()->first, y = prev(mp[i].end())->first; if(x!=l[i]+1 or y!=n-r[i]){ cout << "NE" << "\n"; return 0; } } } cout << "DA" << "\n"; return 0; }
#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...