#include <bits/stdc++.h>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 100000 + 3;
int n, l[N], r[N], u[N], d[N], us[N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif // LOCAL
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];
for (int i = 0; i < n; i++){
if (l[i] + r[i] >= n){
cout << "NE";
return 0;
}
}
for (int i = 0; i < n; i++){
if (u[i] + d[i] >= n){
cout << "NE";
return 0;
}
}
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)){
cout << "NE";
return 0;
}
}
for (int i = 0; i < n; i++){
if (l[i] != -1 && u[l[i]] > i || u[l[i]] == -1){
cout << "NE";
return 0;
}
if (r[i] != -1 && u[n - 1 - r[i]] > i || u[n - 1 - r[i]] == -1){
cout << "NE";
return 0;
}
if (l[i] != -1 && !(l[u[l[i]]] <= l[i] && n - 1 - r[u[l[i]]] >= l[i])){
cout << "NE";
return 0;
}
if (l[i] != -1 && !(l[u[l[i]]] <= n - 1 - r[i] && n - 1 - r[u[l[i]]] >= n - 1 - r[i])){
cout << "NE";
return 0;
}
}
cout << "DA";
}
Compilation message
kocka.cpp: In function 'int main()':
kocka.cpp:44:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if (l[i] != -1 && u[l[i]] > i || u[l[i]] == -1){
~~~~~~~~~~~^~~~~~~~~~~~~~
kocka.cpp:48:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if (r[i] != -1 && u[n - 1 - r[i]] > i || u[n - 1 - r[i]] == -1){
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |