結果

問題 No.2540 同値性判定
ユーザー 👑 hitonanodehitonanode
提出日時 2023-11-10 23:03:01
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,500 ms
コード長 1,783 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 134,280 KB
実行使用メモリ 43,920 KB
最終ジャッジ日時 2023-11-10 23:03:08
合計ジャッジ時間 7,141 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 7 ms
8,192 KB
testcase_15 AC 23 ms
43,920 KB
testcase_16 AC 47 ms
43,920 KB
testcase_17 AC 47 ms
43,920 KB
testcase_18 AC 46 ms
43,920 KB
testcase_19 AC 40 ms
43,920 KB
testcase_20 AC 46 ms
43,920 KB
testcase_21 AC 47 ms
43,920 KB
testcase_22 AC 47 ms
43,920 KB
testcase_23 AC 46 ms
43,920 KB
testcase_24 AC 46 ms
43,920 KB
evil_00.txt AC 276 ms
43,920 KB
evil_01.txt AC 280 ms
43,920 KB
evil_02.txt AC 204 ms
43,920 KB
evil_03.txt AC 201 ms
43,920 KB
evil_04.txt AC 272 ms
43,920 KB
evil_05.txt AC 269 ms
43,920 KB
evil_06.txt AC 210 ms
43,920 KB
evil_07.txt AC 203 ms
43,920 KB
evil_08.txt AC 286 ms
43,920 KB
evil_09.txt AC 273 ms
43,920 KB
evil_10.txt AC 286 ms
43,920 KB
evil_11.txt AC 284 ms
43,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#include <atcoder/lazysegtree>

using ull = unsigned long long;
using S = ull;

S op(S l, S) { return l; }
S e() { return 0; }

using F = pair<ull, ull>; // to0, to1

S mapping(F f, S x) { return (~x & f.first) | (x & f.second); }

F composition(F f, F g) {
    auto [f0, f1] = f;
    auto [g0, g1] = g;
    return {(g0 & f1) | (~g0 & f0), (g1 & f1) | (~g1 & f0)};
}

ull gen(int d) {
    ull ret = 0;
    for (int x = 0; x < 64; ++x) {
        if ((x >> d) & 1) ret |= ull(1) << x;
    }
    return ret;
}

constexpr ull all = ull(-1);
F id() { return {0, all}; }

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;
    vector<S> init(N);
    {
        vector<S> P(6);
        for (int i = 0; i < 6; ++i) P.at(i) = gen(i);
        for (int i = 0; i < N; ++i) init.at(i) = P.at(i % 6);
    }

    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(init);

    unordered_set<ull> us;
    while (Q--) {
        int h;
        string o;
        int l, r;
        cin >> h >> o >> l >> r;
        const S y = seg.get(h);
        F f;
        if (o == "land") {
            f = {0, y};
        } else if (o == "lor") {
            f = {y, all};
        } else if (o == "Rightarrow") {
            f = {all, y};
        } else {
            assert(false);
        }
        seg.apply(l, r + 1, f);

        cin >> l >> r;

        bool ok = false;
        us.clear();

        for (int i = l; i <= r; ++i) {
            const S x = seg.get(i);
            if (us.count(x)) {
                ok = true;
                break;
            }
            us.insert(x);
        }

        cout << (ok ? "Yes" : "No") << "\n";
    }
}
0