結果

問題 No.961 Vibrant Fillumination
ユーザー PachicobuePachicobue
提出日時 2019-10-21 16:37:03
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,557 bytes
コンパイル時間 3,292 ms
コンパイル使用メモリ 95,188 KB
実行使用メモリ 624,196 KB
最終ジャッジ日時 2023-08-20 13:07:15
合計ジャッジ時間 137,657 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1,781 ms
329,672 KB
testcase_03 AC 1,743 ms
329,684 KB
testcase_04 AC 1,723 ms
329,628 KB
testcase_05 AC 1,712 ms
329,656 KB
testcase_06 AC 1,713 ms
329,652 KB
testcase_07 AC 1,709 ms
329,636 KB
testcase_08 AC 1,713 ms
329,660 KB
testcase_09 AC 1,719 ms
329,620 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 AC 855 ms
325,668 KB
testcase_27 MLE -
testcase_28 AC 1,027 ms
325,616 KB
testcase_29 MLE -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 3,247 ms
487,980 KB
testcase_35 AC 2,768 ms
406,448 KB
testcase_36 AC 2,518 ms
365,608 KB
testcase_37 AC 2,389 ms
365,556 KB
testcase_38 AC 2,294 ms
365,488 KB
testcase_39 AC 2,218 ms
357,376 KB
testcase_40 AC 2,168 ms
345,476 KB
testcase_41 AC 2,117 ms
344,964 KB
testcase_42 AC 2,060 ms
344,964 KB
testcase_43 AC 2,024 ms
344,940 KB
testcase_44 AC 2,046 ms
344,948 KB
testcase_45 AC 2,015 ms
344,888 KB
testcase_46 AC 2,023 ms
344,892 KB
testcase_47 AC 1,903 ms
335,920 KB
testcase_48 AC 2,008 ms
344,952 KB
testcase_49 AC 1,965 ms
344,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using ull   = unsigned long long;
using usize = std::size_t;
int main()
{
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false);
    usize N;
    std::cin >> N;
    std::vector<ull> h(N + 1, 0ULL);
    for (usize i = 1; i <= N; i++) { std::cin >> h[i]; }

    const usize L = 2 * N;
    std::vector<usize> a(N + 1, 0), b(N + 1, 0), c(N + 1, L), d(N + 1, L), e(N + 1, 0);
    std::vector<int> lr(L + 1, 0), du(L + 1, 0);
    for (usize i = 1; i <= N; i++) {
        std::cin >> a[i] >> b[i] >> c[i] >> d[i] >> e[i];
        lr[++a[i]] = du[++b[i]] = int(i), lr[++c[i]] = du[++d[i]] = -int(i);
    }
    constexpr usize BS = 700;
    const usize BN     = (L + BS) / BS;
    std::vector<std::vector<ull>> hashs(BN, std::vector<ull>(BN, 0ULL));
    std::vector<std::vector<std::vector<usize>>> cs(BN, std::vector<std::vector<usize>>(BN));
    std::vector<std::vector<std::vector<usize>>> cnt(BN, std::vector<std::vector<usize>>(BN));
    for (usize x = 0; x < L; x++) {
        for (usize yn = 0; yn < BN; yn++) {
            const usize xind = (usize)std::abs(lr[x + 1]);
            if (xind != 0) { cs[x / BS][yn].push_back(e[xind]); }
        }
    }
    for (usize xn = 0; xn < BN; xn++) {
        for (usize y = 0; y < L; y++) {
            const usize yind = (usize)std::abs(du[y + 1]);
            if (yind != 0) { cs[xn][y / BS].push_back(e[yind]); }
        }
    }
    for (usize xn = 0; xn < BN; xn++) {
        for (usize yn = 0; yn < BN; yn++) {
            std::sort(cs[xn][yn].begin(), cs[xn][yn].end());
            cs[xn][yn].erase(std::unique(cs[xn][yn].begin(), cs[xn][yn].end()), cs[xn][yn].end());
        }
    }
    std::vector<usize> color_cnt(N + 1, 0);
    ull hash      = 0;
    auto von      = [&](const usize x, const usize y) { return b[(usize)std::abs(lr[x])] <= y and y < d[(usize)std::abs(lr[x])]; };
    auto hon      = [&](const usize x, const usize y) { return a[(usize)std::abs(du[y])] <= x and x < c[(usize)std::abs(du[y])]; };
    auto add_film = [&](const usize i) {
        const usize c = e[i];
        if (color_cnt[c]++ == 0) { hash ^= h[c]; }
    };
    auto del_film = [&](const usize i) {
        const usize c = e[i];
        if (--color_cnt[c] == 0) { hash ^= h[c]; }
    };
    auto add_del_film = [&](const int i) {
        if (i > 0) { add_film(usize(i)); }
        if (i < 0) { del_film(usize(-i)); }
    };
    for (usize i = 0; i < BN; i++) {
        hash    = 0, std::fill(color_cnt.begin(), color_cnt.end(), 0);
        usize x = i * BS, y = 0;
        for (usize j = 0; j < BN; j++) {
            for (const usize ci : cs[i][j]) { cnt[i][j].push_back(color_cnt[ci]); }
            hashs[i][j]    = hash;
            const usize ny = std::min((j + 1) * BS, L);
            for (; y < ny; y++) {
                if (hon(x, y + 1)) { add_del_film(du[y + 1]); }
            }
        }
    }
    usize Q;
    std::cin >> Q;
    for (usize i = 0, p, q; i < Q; i++) {
        std::cin >> p >> q, p++, q++;
        const usize xi = p / BS, yi = q / BS;
        usize x = xi * BS, y = yi * BS;
        hash = hashs[xi][yi];
        for (const usize ci : cs[xi][yi]) { color_cnt[ci] = cnt[xi][yi][(usize)(std::lower_bound(cs[xi][yi].begin(), cs[xi][yi].end(), ci) - cs[xi][yi].begin())]; }
        for (; x < p; x++) {
            if (von(x + 1, y)) { add_del_film(lr[x + 1]); }
        }
        for (; y < q; y++) {
            if (hon(x, y + 1)) { add_del_film(du[y + 1]); }
        }
        std::cout << hash << "\n";
    }

    return 0;
}
0