#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
9856 KB |
Output is correct |
2 |
Correct |
10 ms |
9728 KB |
Output is correct |
3 |
Correct |
12 ms |
9956 KB |
Output is correct |
4 |
Correct |
11 ms |
9728 KB |
Output is correct |
5 |
Correct |
11 ms |
9984 KB |
Output is correct |
6 |
Correct |
10 ms |
9728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
9984 KB |
Output is correct |
2 |
Correct |
11 ms |
9984 KB |
Output is correct |
3 |
Correct |
11 ms |
9984 KB |
Output is correct |
4 |
Correct |
11 ms |
9984 KB |
Output is correct |
5 |
Correct |
11 ms |
9984 KB |
Output is correct |
6 |
Correct |
12 ms |
9728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
141 ms |
19720 KB |
Output is correct |
2 |
Correct |
186 ms |
32368 KB |
Output is correct |
3 |
Correct |
175 ms |
32556 KB |
Output is correct |
4 |
Correct |
85 ms |
12508 KB |
Output is correct |
5 |
Correct |
172 ms |
32544 KB |
Output is correct |
6 |
Correct |
173 ms |
32376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
160 ms |
30112 KB |
Output is correct |
2 |
Correct |
86 ms |
12580 KB |
Output is correct |
3 |
Correct |
177 ms |
32324 KB |
Output is correct |
4 |
Correct |
131 ms |
31352 KB |
Output is correct |
5 |
Correct |
181 ms |
32420 KB |
Output is correct |
6 |
Correct |
161 ms |
32092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
136 ms |
19704 KB |
Output is correct |
2 |
Correct |
87 ms |
12536 KB |
Output is correct |
3 |
Correct |
173 ms |
32348 KB |
Output is correct |
4 |
Correct |
183 ms |
32604 KB |
Output is correct |
5 |
Correct |
172 ms |
32392 KB |
Output is correct |
6 |
Correct |
83 ms |
12536 KB |
Output is correct |