# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
477017 | rainboy | Kocka (COCI18_kocka) | C11 | 63 ms | 5348 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 <stdio.h>
#include <string.h>
#define N 100000
int main() {
static int ll[N], rr[N], uu[N], dd[N], ii1[N], ii2[N], jj1[N], jj2[N];
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &ll[i]);
for (i = 0; i < n; i++)
scanf("%d", &rr[i]);
for (j = 0; j < n; j++)
scanf("%d", &uu[j]);
for (j = 0; j < n; j++)
scanf("%d", &dd[j]);
for (i = 0; i < n; i++) {
if ((ll[i] == -1) != (rr[i] == -1) || ll[i] + rr[i] >= n) {
printf("NE\n");
return 0;
}
if (ll[i] == -1)
ll[i] = rr[i] = n;
rr[i] = n - 1 - rr[i];
}
for (i = 0; i < n; i++) {
if ((uu[i] == -1) != (dd[i] == -1) || uu[i] + dd[i] >= n) {
printf("NE\n");
return 0;
}
if (uu[i] == -1)
uu[i] = dd[i] = n;
dd[i] = n - 1 - dd[i];
}
for (j = 0; j < n; j++)
ii1[j] = n, ii2[j] = -1;
for (i = 0; i < n; i++) {
if ((j = ll[i]) != n) {
if (ii1[j] == -1)
ii1[j] = i;
ii2[j] = i;
}
if ((j = rr[i]) != -1) {
if (ii1[j] == -1)
ii1[j] = i;
ii2[j] = i;
}
}
for (j = 0; j < n; j++)
if (ii1[j] < uu[j] || ii2[j] > dd[j]) {
printf("NE\n");
return 0;
}
for (i = 0; i < n; i++)
jj1[i] = n, jj2[i] = -1;
for (j = 0; j < n; j++) {
if ((i = uu[j]) != n) {
if (jj1[i] == -1)
jj1[i] = j;
jj2[i] = j;
}
if ((i = dd[j]) != -1) {
if (jj1[i] == -1)
jj1[i] = j;
jj2[i] = j;
}
}
for (i = 0; i < n; i++)
if (jj1[i] < ll[i] || jj2[i] > rr[i]) {
printf("NE\n");
return 0;
}
printf("DA\n");
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... |