답안 #923899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923899 2024-02-08T05:34:48 Z Pring Kocka (COCI18_kocka) C++17
70 / 70
207 ms 51600 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
#define debug(x...) cout << '[' << #x << "] : ", dout(x)
void dout() { cout << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;

const int MXN = 100005;
int n, l[MXN], r[MXN], u[MXN], d[MXN];
set<int> SH[MXN], SV[MXN];

void PUT(int x, int y) {
    SH[x].insert(y);
    SV[y].insert(x);
}

bool miku() {
    cin >> n;
    FOR(i, 1, n + 1) cin >> l[i];
    FOR(i, 1, n + 1) cin >> r[i];
    FOR(i, 1, n + 1) cin >> u[i];
    FOR(i, 1, n + 1) cin >> d[i];
    FOR(i, 1, n + 1) {
        if (l[i] == -1 && r[i] == -1) continue;
        if (l[i] == -1 || r[i] == -1) return false;
        PUT(i, l[i] + 1);
        PUT(i, n - r[i]);
    }
    FOR(i, 1, n + 1) {
        if (u[i] == -1 && d[i] == -1) continue;
        if (u[i] == -1 || d[i] == -1) return false;
        PUT(u[i] + 1, i);
        PUT(n - d[i], i);
    }
    FOR(i, 1, n + 1) {
        if (l[i] == -1) {
            if (SH[i].size()) return false;
            continue;
        }
        if (*SH[i].begin() != l[i] + 1) return false;
        if (*SH[i].rbegin() != n - r[i]) return false;
    }
    FOR(i, 1, n + 1) {
        if (u[i] == -1) {
            if (SV[i].size()) return false;
            continue;
        }
        if (*SV[i].begin() != u[i] + 1) return false;
        if (*SV[i].rbegin() != n - d[i]) return false;
    }
    return true;
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(iostream::failbit);
    cout << (miku() ? "DA" : "NE") << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 12888 KB Output is correct
2 Correct 3 ms 12892 KB Output is correct
3 Correct 3 ms 12892 KB Output is correct
4 Correct 4 ms 13152 KB Output is correct
5 Correct 3 ms 13252 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12888 KB Output is correct
2 Correct 3 ms 13144 KB Output is correct
3 Correct 3 ms 12956 KB Output is correct
4 Correct 3 ms 13144 KB Output is correct
5 Correct 3 ms 12892 KB Output is correct
6 Correct 2 ms 12892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 23888 KB Output is correct
2 Correct 68 ms 29852 KB Output is correct
3 Correct 98 ms 36856 KB Output is correct
4 Correct 20 ms 14168 KB Output is correct
5 Correct 40 ms 23120 KB Output is correct
6 Correct 34 ms 20724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 188 ms 48844 KB Output is correct
2 Correct 20 ms 14112 KB Output is correct
3 Correct 29 ms 16668 KB Output is correct
4 Correct 207 ms 51600 KB Output is correct
5 Correct 150 ms 44544 KB Output is correct
6 Correct 193 ms 48724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 23892 KB Output is correct
2 Correct 25 ms 14152 KB Output is correct
3 Correct 47 ms 25424 KB Output is correct
4 Correct 50 ms 26452 KB Output is correct
5 Correct 34 ms 20824 KB Output is correct
6 Correct 21 ms 14164 KB Output is correct