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>
#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 (stderr)
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 |
---|
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... |