Submission #228943

#TimeUsernameProblemLanguageResultExecution timeMemory
228943VEGAnnKocka (COCI18_kocka)C++14
70 / 70
50 ms2040 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100100; int n, l[N], r[N], u[N], d[N]; void BAD(){ cout << "NE"; exit(0); } void calc(){ for (int i = 0; i < n; i++){ if (l[i] < 0 && r[i] < 0) continue; if (l[i] < 0 || r[i] < 0) BAD(); if (l[i] + r[i] + 1 > n) BAD(); int fi = l[i]; int se = n - 1 - r[i]; if (u[fi] < 0 || u[se] < 0) BAD(); if (d[fi] < 0 || d[se] < 0) BAD(); if (u[fi] > i || n - 1 - d[fi] < i) BAD(); if (u[se] > i || n - 1 - d[se] < i) BAD(); } } int main(){ ios_base::sync_with_stdio(0); cin.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]; calc(); for (int i = 0; i < n; i++){ swap(l[i], u[i]); swap(r[i], d[i]); } calc(); 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...