Submission #105126

#TimeUsernameProblemLanguageResultExecution timeMemory
105126leonardaKocka (COCI18_kocka)C++14
70 / 70
66 ms4344 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define F first #define S second typedef pair<int, int> pi; typedef long long int lint; const int inf = 0x3f3f3f3f; const int maxn = 1e5 + 10; int n; int l[maxn], r[maxn], d[maxn], u[maxn]; int main () { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 0; i < n; ++i) cin >> l[i]; for(int i = 0; i < n; ++i) cin >> r[i]; for(int i = 0; i < n; ++i) cin >> u[i]; for(int i = 0; i < n; ++i) cin >> d[i]; for(int i = 0; i < n; ++i) { // cout << i << endl; if(d[i] != -1) if(l[n - 1 - d[i]] == -1 or r[n - 1 - d[i]] == -1) return cout << "NE", 0; if(u[i] != -1) if(l[u[i]] == -1 or r[u[i]] == -1) return cout << "NE", 0; if(l[i] != -1) if(d[l[i]] == -1 or u[l[i]] == -1) return cout << "NE", 0; if(r[i] != -1) if(d[n - 1 - r[i]] == -1 or u[n - 1 - r[i]] == -1) return cout << "NE", 0; if(l[i] == -1 and r[i] != -1) return cout << "NE", 0; if(r[i] == -1 and l[i] != -1) return cout << "NE", 0; if(d[i] == -1 and u[i] != -1) return cout << "NE", 0; if(u[i] == -1 and d[i] != -1) return cout << "NE", 0; if(d[i] + u[i] >= n or l[i] + r[i] >= n) return cout << "NE", 0; if(u[i] != -1) if(l[u[i]] > i or r[u[i]] > n - i - 1) return cout << "NE", 0; if(d[i] != -1) if(l[n - 1 - d[i]] > i or r[n - 1 - d[i]] > n - i - 1) return cout << "NE", 0; if(l[i] != -1) if(d[l[i]] > n - i - 1 or u[l[i]] > i) return cout << "NE", 0; if(r[i] != -1) if(u[n - 1 - r[i]] > i or d[n - 1 - r[i]] > n - i - 1) return cout << "NE", 0; } cout << "DA"; 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...