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;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<int> l(n), r(n), d(n), u(n);
for (int &i: l)
cin >> i;
for (int &i: r)
cin >> i;
for (int &i: u)
cin >> i;
for (int &i: d)
cin >> i;
bool ok = true;
for (int i = 0; i < n; ++i)
if ((l[i] == -1 && r[i] != -1) || (l[i] != -1 && r[i] == -1) || (u[i] == -1 && d[i] != -1) || (u[i] != -1 && d[i] == -1) || (l[i] + r[i] >= n) || (u[i] + d[i] >= n) || u[l[i]] > i || d[l[i]] > (n - 1 - i) || u[r[i]] > i || u[r[i]] > n - 1 - i || u[l[i]] == -1 || d[l[i]] == -1 || u[r[i]] == -1 || d[r[i]] == -1 || l[u[i]] > i || l[d[i]] > (n - 1 - i) || r[u[i]] > i || r[u[i]] > n - 1 - i || l[u[i]] == -1 || l[d[i]] == -1 || r[u[i]] == -1 || r[d[i]] == -1)
ok = false;
cout << (ok ? "DA" : "NE");
}
# | 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... |