제출 #406683

#제출 시각아이디문제언어결과실행 시간메모리
406683tengiz05가로등 (APIO19_street_lamps)C++17
20 / 100
132 ms10968 KiB
#include <bits/stdc++.h>
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, q;
    std::cin >> n >> q;
    std::string v;
    std::cin >> v;
    std::vector<int> last(n, -1), ans(n);
    for (int it = 0; it < q; it++) {
        std::string type;
        std::cin >> type;
        if (type == "query") {
            int l, r;
            std::cin >> l >> r;
            l--;
            r-=2;
            int res = ans[l];
            if (v[l] == '1') res += (it - last[l]);
            std::cout << res << "\n";
        } else {
            int p;
            std::cin >> p;
            p--;
            if (v[p] == '1') {
                ans[p] += it - last[p];
            } else {
                last[p] = it;
            }
            v[p] ^= 1;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...