# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305496 | phathnv | Kocka (COCI18_kocka) | C++11 | 65 ms | 4216 KiB |
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 mp make_pair
#define X first
#define Y second
#define taskname "Kocka"
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
const int N = 1e5 + 1;
int n, l[N], r[N], u[N], d[N];
void readInput(){
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d", &l[i]);
for(int i = 1; i <= n; i++)
scanf("%d", &r[i]);
for(int i = 1; i <= n; i++)
scanf("%d", &u[i]);
for(int i = 1; i <= n; i++)
scanf("%d", &d[i]);
}
bool construct(int l[], int r[]){
for(int i = 1; i <= n; i++)
if (l[i] + r[i] == -2){
l[i] = -1;
r[i] = -1;
} else if (min(l[i], r[i]) > -1){
if (l[i] + r[i] >= n)
return 0;
l[i] = l[i] + 1;
r[i] = n - r[i];
} else {
return 0;
}
return 1;
}
bool check(int a[], int l[], int r[]){
for(int i = 1; i <= n; i++){
if (a[i] == -1)
continue;
if (i < l[a[i]] || r[a[i]] < i)
return 0;
}
return 1;
}
void solve(){
if (!construct(l, r) || !construct(u, d)){
printf("NE");
return;
}
if (check(l, u, d) &&
check(r, u, d) &&
check(u, l, r) &&
check(d, l, r))
printf("DA");
else
printf("NE");
}
int main(){
//freopen(taskname".inp", "r", stdin);
//freopen(taskname".out", "w", stdout);
readInput();
solve();
return 0;
}
Compilation message (stderr)
# | 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... |