Submission #86969

# Submission time Handle Problem Language Result Execution time Memory
86969 2018-11-29T02:28:23 Z FutymyClone Kocka (COCI18_kocka) C++14
70 / 70
73 ms 3808 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, l[N], r[N], a[5][N], u[N], d[N];
bool has[N];

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= 4; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
    for (int i = 1; i <= n; i++) {
        if (a[1][i] == -1 && a[2][i] != -1) return !printf("NE");
        if (a[1][i] != -1 && a[2][i] == -1) return !printf("NE");
        if (a[1][i] + a[2][i] >= n) return !printf("NE");
        if (a[3][i] == -1 && a[4][i] != -1) return !printf("NE");
        if (a[3][i] != -1 && a[4][i] == -1) return !printf("NE");
        if (a[3][i] + a[4][i] >= n) return !printf("NE");
    }
    for (int i = 1; i <= n; i++) {
        int lef = a[1][i], rig = a[2][i];
        if (lef == -1) lef = -1;
        if (rig == -1) rig = -1;
        l[i] = lef + 1, r[i] = n - rig;
        has[l[i]] = true; has[r[i]] = true;
    }

    //for (int i = 1; i <= n; i++) cout << l[i] << " " << r[i] << "\n";
    for (int i = 1; i <= n; i++) {
        if (a[3][i] == -1 || a[4][i] == -1) {
            if (has[i]) return !printf("NE");
            continue;
        }
        int frow = a[3][i] + 1, lrow = n - a[4][i];
        if (i < l[frow] || i > r[frow] || i < l[lrow] || i > r[lrow]) return !printf("NE");
    }

    memset(has, 0, sizeof(has));
    for (int i = 1; i <= n; i++) {
        int up = a[3][i], down = a[4][i];
        if (up == -1) up = -1;
        if (down == -1) down = -1;
        u[i] = up + 1, d[i] = n - down;
        has[u[i]] = true; has[d[i]] = true;
    }

    //for (int i = 1; i <= n; i++) cout << u[i] << " " << d[i] << "\n";
    for (int i = 1; i <= n; i++) {
        if (a[1][i] == -1 || a[2][i] == -1) {
            if (has[i]) return !printf("NE");
            continue;
        }
        int lcol = a[1][i] + 1, rcol = n - a[2][i];
        if (i < u[lcol] || i > d[lcol] || i < u[rcol] || i > d[rcol]) return !printf("NE");
    }

    printf("DA");
    return 0;
}

Compilation message

kocka.cpp: In function 'int main()':
kocka.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
kocka.cpp:12:68: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= 4; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
                                                               ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 628 KB Output is correct
3 Correct 2 ms 628 KB Output is correct
4 Correct 2 ms 628 KB Output is correct
5 Correct 2 ms 628 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 628 KB Output is correct
2 Correct 3 ms 648 KB Output is correct
3 Correct 2 ms 648 KB Output is correct
4 Correct 2 ms 668 KB Output is correct
5 Correct 2 ms 668 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 3772 KB Output is correct
2 Correct 59 ms 3772 KB Output is correct
3 Correct 64 ms 3772 KB Output is correct
4 Correct 73 ms 3792 KB Output is correct
5 Correct 59 ms 3792 KB Output is correct
6 Correct 63 ms 3792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 3792 KB Output is correct
2 Correct 42 ms 3792 KB Output is correct
3 Correct 73 ms 3792 KB Output is correct
4 Correct 52 ms 3792 KB Output is correct
5 Correct 65 ms 3792 KB Output is correct
6 Correct 70 ms 3792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 3808 KB Output is correct
2 Correct 45 ms 3808 KB Output is correct
3 Correct 73 ms 3808 KB Output is correct
4 Correct 68 ms 3808 KB Output is correct
5 Correct 64 ms 3808 KB Output is correct
6 Correct 41 ms 3808 KB Output is correct