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 <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
using namespace std;
const int N = 100005;
int n;
int l[N], r[N], d[N], u[N];
set <int> row[N], col[N];
void no() {
cout << "NE" << endl;
exit(0);
}
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> l[i];
if (l[i] != -1) {
row[i].insert(l[i] + 1);
}
}
for (int i = 1; i <= n; i++) {
cin >> r[i];
if (r[i] != -1) {
row[i].insert(n - r[i]);
}
}
for (int i = 1; i <= n; i++) {
cin >> u[i];
if (u[i] != -1) {
col[i].insert(u[i] + 1);
}
}
for (int i = 1; i <= n; i++) {
cin >> d[i];
if (d[i] != -1) {
col[i].insert(n - d[i]);
}
}
for (int i = 1; i <= n; i++) {
if (l[i] == -1 && row[i].size()) no();
if (l[i] != -1 && (!row[i].size() || *row[i].begin() != l[i] + 1)) no();
if (r[i] == -1 && row[i].size()) no();
if (r[i] != -1 && (!row[i].size() || *row[i].rbegin() != n - r[i])) no();
if (u[i] == -1 && col[i].size()) no();
if (u[i] != -1 && (!col[i].size() || *col[i].begin() != u[i] + 1)) no();
if (d[i] == -1 && col[i].size()) no();
if (d[i] != -1 && (!col[i].size() || *col[i].rbegin() != n - d[i])) no();
}
cout << "DA" << endl;
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... |