結果

問題 No.2540 同値性判定
ユーザー hitonanode
提出日時 2023-11-10 23:03:01
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 62 ms / 2,500 ms
コード長 1,783 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 132,680 KB
実行使用メモリ 43,868 KB
最終ジャッジ日時 2024-09-26 02:07:52
合計ジャッジ時間 7,123 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

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