Submission #50405999


Source Code Expand

#include <bits/stdc++.h>

namespace {
    using Num = long long int;
    using Set = std::set<Num>;
}

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

    Set eqs;
    for(Num i{0}; i<(n-1); ++i) {
        const auto d = (s.at(i+1) != s.at(i));
        if (!d) {
            eqs.insert(i);
        }
    }

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

        if (cmd == 1) {
            if (l > 0) {
                const auto x = l - 1;
                if (eqs.contains(x)) {
                    eqs.erase(x);
                } else {
                    eqs.insert(x);
                }
            }

            if ((r+1) < n) {
                if (eqs.contains(r)) {
                    eqs.erase(r);
                } else {
                    eqs.insert(r);
                }
            }
        } else {
            auto it = eqs.lower_bound(l);
            if ((it == eqs.end()) || (*it >= 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 1282 Byte
Status AC
Exec Time 974 ms
Memory 27212 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 3564 KiB
example_01.txt AC 1 ms 3608 KiB
hand_00.txt AC 416 ms 4276 KiB
hand_01.txt AC 426 ms 4208 KiB
hand_02.txt AC 443 ms 4224 KiB
hand_03.txt AC 456 ms 27140 KiB
hand_04.txt AC 598 ms 3500 KiB
hand_05.txt AC 432 ms 27084 KiB
hand_06.txt AC 446 ms 4268 KiB
hand_07.txt AC 357 ms 8416 KiB
hand_08.txt AC 374 ms 8400 KiB
hand_09.txt AC 330 ms 6016 KiB
random_00.txt AC 896 ms 27152 KiB
random_01.txt AC 974 ms 27196 KiB
random_02.txt AC 908 ms 27124 KiB
random_03.txt AC 923 ms 27212 KiB
random_04.txt AC 103 ms 27152 KiB
random_05.txt AC 104 ms 27088 KiB
random_06.txt AC 504 ms 4200 KiB
random_07.txt AC 727 ms 13760 KiB
random_08.txt AC 479 ms 4200 KiB
random_09.txt AC 702 ms 12144 KiB
random_10.txt AC 7 ms 4160 KiB
random_11.txt AC 7 ms 4380 KiB
random_12.txt AC 504 ms 4156 KiB
random_13.txt AC 722 ms 13904 KiB
random_14.txt AC 475 ms 4136 KiB
random_15.txt AC 690 ms 12116 KiB
random_16.txt AC 7 ms 4136 KiB
random_17.txt AC 7 ms 4184 KiB
random_18.txt AC 679 ms 8480 KiB
random_19.txt AC 780 ms 14148 KiB
random_20.txt AC 694 ms 9508 KiB
random_21.txt AC 715 ms 12356 KiB
random_22.txt AC 18 ms 7076 KiB
random_23.txt AC 17 ms 6904 KiB
random_24.txt AC 681 ms 9208 KiB
random_25.txt AC 768 ms 14216 KiB
random_26.txt AC 684 ms 9240 KiB
random_27.txt AC 720 ms 12316 KiB
random_28.txt AC 16 ms 6512 KiB
random_29.txt AC 19 ms 7152 KiB