제출 #1234236

#제출 시각아이디문제언어결과실행 시간메모리
1234236kaltspielerhyStreet Lamps (APIO19_street_lamps)C++20
20 / 100
5095 ms589824 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, Q;
    cin >> N >> Q;
    cin.ignore();
    string elements;
    getline(cin, elements);
    vector<string> chaines;
    chaines.push_back(elements);

    for (int i = 1; i <= Q; i++) {
        string type;
        cin >> type;
        if (type == "toggle") {
            int num;
            cin >> num;
            elements[num-1] = (elements[num-1] == '0' ? '1' : '0');
        }
        else {
            int a, b;
            cin >> a >> b;
            a--; b--;
            int res = 0;
            for (int iChaine = 0; iChaine < i; iChaine++) {
                bool broken = false;
                for (int iChar = a; iChar < b; iChar++) {
                    if (chaines[iChaine][iChar] == '0') {
                        broken = true;
                        break;
                    }
                }
                if (!broken) res++;
            }
            cout << res << '\n';
        }
        cin.ignore();
        chaines.push_back(elements);
    }
}
#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...