# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92151 | Kastanda | Kocka (COCI18_kocka) | C++11 | 62 ms | 5916 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>
using namespace std;
const int N = 100005;
int n, L[N], R[N], U[N], D[N];
int l[N], r[N], u[N], d[N];
inline void Upd(int x, int y)
{
if (y >= 1) L[x] = min(L[x], y);
if (y <= n) R[x] = max(R[x], y);
if (x >= 1) U[y] = min(U[y], x);
if (x <= n) D[y] = max(D[y], x);
}
int main()
{
scanf("%d", &n);
memset(L, 63, sizeof(L));
memset(R, -1, sizeof(R));
memset(U, 63, sizeof(U));
memset(D, -1, sizeof(D));
for (int i = 1; i <= n; i++)
{
scanf("%d", &l[i]);
if (l[i] != -1) l[i] ++;
else l[i] = n + 1;
Upd(i, l[i]);
}
for (int i = 1; i <= n; i++)
{
scanf("%d", &r[i]);
if (r[i] != -1) r[i] = n - r[i];
else r[i] = 0;
Upd(i, r[i]);
}
for (int i = 1; i <= n; i++)
{
scanf("%d", &u[i]);
if (u[i] != -1) u[i] ++;
else u[i] = n + 1;
Upd(u[i], i);
}
for (int i = 1; i <= n; i++)
{
scanf("%d", &d[i]);
if (d[i] != -1) d[i] = n - d[i];
else d[i] = 0;
Upd(d[i], i);
}
bool Fail = 0;
for (int i = 1; i <= n; i++)
{
if (l[i] != L[i]) Fail = 1;
if (r[i] != R[i]) Fail = 1;
if (u[i] != U[i]) Fail = 1;
if (d[i] != D[i]) Fail = 1;
}
puts(Fail ? "NE" : "DA");
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... |