#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
1920 KB |
Output is correct |
2 |
Correct |
43 ms |
1912 KB |
Output is correct |
3 |
Correct |
49 ms |
1916 KB |
Output is correct |
4 |
Correct |
32 ms |
1912 KB |
Output is correct |
5 |
Correct |
43 ms |
1912 KB |
Output is correct |
6 |
Correct |
44 ms |
1912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
1912 KB |
Output is correct |
2 |
Correct |
32 ms |
1912 KB |
Output is correct |
3 |
Correct |
43 ms |
1912 KB |
Output is correct |
4 |
Correct |
37 ms |
1912 KB |
Output is correct |
5 |
Correct |
49 ms |
2016 KB |
Output is correct |
6 |
Correct |
42 ms |
2040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
1912 KB |
Output is correct |
2 |
Correct |
34 ms |
1920 KB |
Output is correct |
3 |
Correct |
46 ms |
1912 KB |
Output is correct |
4 |
Correct |
48 ms |
1912 KB |
Output is correct |
5 |
Correct |
46 ms |
1920 KB |
Output is correct |
6 |
Correct |
33 ms |
1912 KB |
Output is correct |