Submission #522422

# Submission time Handle Problem Language Result Execution time Memory
522422 2022-02-05T01:36:58 Z KoD Kocka (COCI18_kocka) C++17
70 / 70
49 ms 4400 KB
#include <bits/stdc++.h>

using std::vector;
using std::array;
using std::tuple;
using std::pair;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N;
    std::cin >> N;
    array<vector<int>, 4> A = {};
    for (auto& v : A) {
        v.resize(N);
        for (auto& x : v) {
            std::cin >> x;
        }
    }
    if ([&]() -> bool {
        for (const int k : {0, 2}) {
            for (int i = 0; i < N; ++i) {
                if ((A[k][i] == -1) ^ (A[k + 1][i] == -1)) {
                    return false;
                }
                if (A[k][i] + A[k + 1][i] >= N) {
                    return false;
                }
            }
        }
        for (int i = 0; i < 4; ++i) {
            for (int j = 0; j < 2; ++j) {
                const auto& X = A[0];
                const auto& Y = A[2];
                vector<int> top(N, -1);
                for (int i = 0; i < N; ++i) {
                    if (X[i] != -1 and top[X[i]] != -1) {
                        top[X[i]] = i;
                    }
                }
                for (int i = 0; i < N; ++i) {
                    if (Y[i] == -1 and top[i] != -1) {
                        return false;
                    }
                    if (top[i] != -1 and top[i] < Y[i]) {
                        return false;
                    }
                }
                std::swap(A[0], A[2]);
            }
            std::swap(A[0], A[2]);
            std::swap(A[1], A[3]);
            std::swap(A[0], A[1]);
            std::reverse(A[2].begin(), A[2].end());
            std::reverse(A[3].begin(), A[3].end());
        }
        return true;
    }()) {
        std::cout << "DA\n";
    } else {
        std::cout << "NE\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 4028 KB Output is correct
2 Correct 28 ms 4152 KB Output is correct
3 Correct 34 ms 4148 KB Output is correct
4 Correct 29 ms 3396 KB Output is correct
5 Correct 30 ms 4156 KB Output is correct
6 Correct 28 ms 4168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 4296 KB Output is correct
2 Correct 24 ms 3384 KB Output is correct
3 Correct 30 ms 4144 KB Output is correct
4 Correct 25 ms 3496 KB Output is correct
5 Correct 28 ms 4176 KB Output is correct
6 Correct 33 ms 4400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 4144 KB Output is correct
2 Correct 22 ms 3380 KB Output is correct
3 Correct 28 ms 4172 KB Output is correct
4 Correct 29 ms 4156 KB Output is correct
5 Correct 31 ms 4276 KB Output is correct
6 Correct 25 ms 3392 KB Output is correct