Submission #701703

#TimeUsernameProblemLanguageResultExecution timeMemory
701703scottchouKocka (COCI18_kocka)C++17
70 / 70
315 ms51160 KiB
#include<bits/stdc++.h> using namespace std; int const N = 1e5 + 5; int l[N], r[N], top[N], bottom[N]; set<int> x[N], y[N]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for(int i = 1; i <= n; i++){ cin >> l[i]; if(l[i] >= 0){ x[i].insert(l[i] + 1); y[l[i] + 1].insert(i); } } for(int i = 1; i <= n; i++){ cin >> r[i]; if(r[i] >= 0){ x[i].insert(n - r[i]); y[n - r[i]].insert(i); } } for(int i = 1; i <= n; i++){ cin >> top[i]; if(top[i] >= 0){ x[top[i] + 1].insert(i); y[i].insert(top[i] + 1); } } for(int i = 1; i <= n; i++){ cin >> bottom[i]; if(bottom[i] >= 0){ x[n - bottom[i]].insert(i); y[i].insert(n - bottom[i]); } } bool can = 1; for(int i = 1; i <= n; i++){ if(l[i] == -1 && !x[i].empty()) can = 0; if(r[i] == -1 && !x[i].empty()) can = 0; if(top[i] == -1 && !y[i].empty()) can = 0; if(bottom[i]== -1 && !y[i].empty()) can = 0; if(!can) break; if((l[i] >= 0 && *x[i].begin() != l[i] + 1) || (r[i] >= 0 && *prev(x[i].end()) != n - r[i]) || (top[i] >= 0 && *y[i].begin() != top[i] + 1) || (bottom[i] >= 0 && *prev(y[i].end()) != n - bottom[i])){ can = 0; break; } } if(can){ cout << "DA\n"; }else{ cout << "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...