結果

問題 No.961 Vibrant Fillumination
ユーザー koprickykopricky
提出日時 2019-10-20 21:08:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,999 bytes
コンパイル時間 1,048 ms
コンパイル使用メモリ 85,648 KB
実行使用メモリ 7,188 KB
最終ジャッジ日時 2023-08-30 20:40:30
合計ジャッジ時間 12,807 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,692 KB
testcase_01 WA -
testcase_02 AC 158 ms
7,136 KB
testcase_03 AC 163 ms
7,028 KB
testcase_04 AC 161 ms
7,004 KB
testcase_05 AC 163 ms
7,008 KB
testcase_06 AC 157 ms
7,048 KB
testcase_07 AC 164 ms
6,952 KB
testcase_08 AC 162 ms
7,016 KB
testcase_09 AC 163 ms
7,176 KB
testcase_10 AC 202 ms
6,928 KB
testcase_11 AC 202 ms
6,920 KB
testcase_12 AC 202 ms
7,024 KB
testcase_13 AC 197 ms
6,972 KB
testcase_14 AC 203 ms
7,012 KB
testcase_15 AC 183 ms
7,064 KB
testcase_16 AC 198 ms
6,912 KB
testcase_17 AC 183 ms
7,032 KB
testcase_18 AC 203 ms
6,932 KB
testcase_19 AC 201 ms
7,000 KB
testcase_20 AC 202 ms
7,188 KB
testcase_21 AC 186 ms
7,072 KB
testcase_22 AC 188 ms
6,956 KB
testcase_23 AC 186 ms
7,008 KB
testcase_24 AC 192 ms
6,952 KB
testcase_25 AC 200 ms
7,036 KB
testcase_26 AC 105 ms
7,180 KB
testcase_27 AC 109 ms
7,088 KB
testcase_28 AC 106 ms
6,968 KB
testcase_29 AC 112 ms
7,004 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 3 ms
5,716 KB
testcase_34 AC 171 ms
6,932 KB
testcase_35 AC 163 ms
7,008 KB
testcase_36 AC 169 ms
7,088 KB
testcase_37 AC 171 ms
6,920 KB
testcase_38 AC 165 ms
6,960 KB
testcase_39 AC 164 ms
7,132 KB
testcase_40 AC 164 ms
7,008 KB
testcase_41 AC 165 ms
7,176 KB
testcase_42 AC 168 ms
7,008 KB
testcase_43 AC 173 ms
7,008 KB
testcase_44 AC 174 ms
6,940 KB
testcase_45 AC 169 ms
6,912 KB
testcase_46 AC 172 ms
6,972 KB
testcase_47 AC 168 ms
7,036 KB
testcase_48 AC 171 ms
7,008 KB
testcase_49 AC 174 ms
7,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

const int MAX_N = 50000;

struct info {
    int lower, upper, color;
    info() : info(2 * MAX_N + 1, -1, 0){}
    info(const int _lower, const int _upper, const int _color)
        : lower(_lower), upper(_upper), color(_color){}
};

info upx[2 * MAX_N], upy[2 * MAX_N];

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int N;
    std::cin >> N;
    std::vector<unsigned long long> h(N);
    for(int i = 0; i < N; ++i){
        std::cin >> h[i];
    }
    for(int i = 0; i < N; ++i){
        int a, b, c, d, e;
        std::cin >> a >> b >> c >> d >> e;
        upx[a] = {b, d, e}, upx[c] = {b, d, -e}, upy[b] = {a, c, e}, upy[d] = {a, c, -e};
    }
    int Q;
    std::cin >> Q;
    std::vector<std::pair<int, int> > z(Q);
    std::vector<int> ord(Q);
    std::iota(ord.begin(), ord.end(), 0);
    for(int i = 0; i < Q; ++i){
        int p, q;
        std::cin >> p >> q;
        z[i] = {p, q};
    }
    const int width = 500;
    // const int width = ceil(sqrt(2 * N));
    std::sort(ord.begin(), ord.end(), [&](const int a, const int b){
        const int u = z[a].first / width, v = z[b].first / width;
        return (u == v) ? (z[a].second < z[b].second) : (u < v);
    });
    std::vector<unsigned long long> ans(Q);
    std::vector<int> C(N, 0);
    unsigned long long cur_hash = 0;
    int prv = -1, curx = -1, cury = -1;
    for(const int id : ord){
        const int cur = z[id].first / width;
        if(prv != cur){
            fill(C.begin(), C.end(), 0), cur_hash = 0, prv = cur, curx = cur * width - 1, cury = -1;
        }
        // left
        while(curx > z[id].first){
            if(upx[curx].lower <= cury && cury < upx[curx].upper){
                const int c = upx[curx].color;
                if(c > 0){
                    if(--C[c - 1] == 0) cur_hash ^= h[c - 1];
                }else{
                    if(++C[-c - 1] == 1) cur_hash ^= h[-c - 1];
                }
            }
            --curx;
        }
        // right
        while(curx < z[id].first){
            ++curx;
            if(upx[curx].lower <= cury && cury < upx[curx].upper){
                const int c = upx[curx].color;
                if(c > 0){
                    if(++C[c - 1] == 1) cur_hash ^= h[c - 1];
                }else{
                    if(--C[-c - 1] == 0) cur_hash ^= h[-c - 1];
                }
            }
        }
        // up
        while(cury < z[id].second){
            ++cury;
            if(upy[cury].lower <= curx && curx < upy[cury].upper){
                const int c = upy[cury].color;
                if(c > 0){
                    if(++C[c - 1] == 1) cur_hash ^= h[c - 1];
                }else{
                    if(--C[-c - 1] == 0) cur_hash ^= h[-c - 1];
                }
            }
        }
        ans[id] = cur_hash;
    }
    for(int i = 0; i < Q; ++i){
        std::cout << ans[i] << "\n";
    }
    return 0;
}
0