This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |