Submission #50405635


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/segtree>

bool apply(bool a, bool b) {
    return a & b;
}

bool unit(void) {
    return true;
}

void solve(std::istream& is, std::ostream& os) {
    using Num = int;
    Num n, q;
    std::string s;
    is >> n >> q >> s;

    const Num size = n + 1;
    using SegTree = atcoder::segtree<bool, apply, unit>;
    SegTree tree(size);

    tree.set(0, true);
    for(Num i{1}; i<n; ++i) {
        const auto d = (s.at(i-1) != s.at(i));
        tree.set(i, d);
    }
    tree.set(n, true);

    auto flip = [&](Num pos) {
        if ((pos > 0) && (pos < n)) {
            tree.set(pos, !tree.get(pos));
        }
    };

    while(q-- > 0) {
        Num cmd, l, r;
        is >> cmd >> l >> r;

        if (cmd == 1) {
            flip(l - 1);
            flip(r);
        } else {
            if (tree.prod(l, r)) {
                os << "Yes\n";
            } else {
                os << "No\n";
            }
        }
    }
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}

Submission Info

Submission Time
Task E - Alternating String
User zettsut
Language C++ 20 (gcc 12.2)
Score 450
Code Size 1093 Byte
Status AC
Exec Time 599 ms
Memory 4356 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 2
AC × 42
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3512 KiB
example_01.txt AC 1 ms 3472 KiB
hand_00.txt AC 479 ms 4196 KiB
hand_01.txt AC 510 ms 4148 KiB
hand_02.txt AC 528 ms 4164 KiB
hand_03.txt AC 355 ms 4192 KiB
hand_04.txt AC 599 ms 3476 KiB
hand_05.txt AC 355 ms 4168 KiB
hand_06.txt AC 534 ms 4204 KiB
hand_07.txt AC 355 ms 4200 KiB
hand_08.txt AC 355 ms 4108 KiB
hand_09.txt AC 355 ms 4192 KiB
random_00.txt AC 579 ms 4160 KiB
random_01.txt AC 581 ms 4204 KiB
random_02.txt AC 597 ms 4356 KiB
random_03.txt AC 576 ms 4228 KiB
random_04.txt AC 57 ms 4144 KiB
random_05.txt AC 57 ms 4260 KiB
random_06.txt AC 580 ms 4208 KiB
random_07.txt AC 582 ms 4176 KiB
random_08.txt AC 599 ms 4192 KiB
random_09.txt AC 579 ms 4152 KiB
random_10.txt AC 57 ms 4204 KiB
random_11.txt AC 58 ms 4112 KiB
random_12.txt AC 580 ms 4192 KiB
random_13.txt AC 581 ms 4264 KiB
random_14.txt AC 594 ms 4264 KiB
random_15.txt AC 579 ms 4152 KiB
random_16.txt AC 57 ms 4176 KiB
random_17.txt AC 58 ms 4208 KiB
random_18.txt AC 585 ms 4312 KiB
random_19.txt AC 582 ms 4260 KiB
random_20.txt AC 596 ms 4172 KiB
random_21.txt AC 578 ms 4156 KiB
random_22.txt AC 57 ms 4176 KiB
random_23.txt AC 57 ms 4236 KiB
random_24.txt AC 586 ms 4264 KiB
random_25.txt AC 582 ms 4184 KiB
random_26.txt AC 597 ms 4192 KiB
random_27.txt AC 578 ms 4164 KiB
random_28.txt AC 58 ms 4116 KiB
random_29.txt AC 58 ms 4176 KiB