제출 #1367074

#제출 시각아이디문제언어결과실행 시간메모리
1367074Nxmkxing가로등 (APIO19_street_lamps)C++20
0 / 100
24 ms1144 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 110;
int n, q;
string s;
int total[N], start[N];

int main() {
    cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    cin >> n >> q >> s;
    for (int i = 1; i <= n; i++) {
        if (s[i-1] == '0') start[i] = -1;
        else start[i] = 0;
    }
    for (int i = 1; i <= q; i++) {
        string type;
        cin >> type;
        if (type == "toggle") {
            int pos;
            cin >> pos;
            if (start[pos] == -1) start[pos] = i;
            else {
                total[pos] += i - start[pos];
                start[pos] = -1;
            }
        } 
        else {
            int a, b;
            cin >> a >> b;
            if (start[a] == -1) cout << total[a] << "\n";
            else cout << total[a] + i - start[a] << "\n";
        }
    }
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…