제출 #952979

#제출 시각아이디문제언어결과실행 시간메모리
952979Vladth11Street Lamps (APIO19_street_lamps)C++14
20 / 100
84 ms21840 KiB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;

const ll NMAX = 300001;
const int INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;

int a[NMAX];
string s[NMAX];
int qa[NMAX];
int qb[NMAX];
int total[NMAX];
int lst[NMAX];

signed main() {
#ifdef HOME
    ifstream cin(".in");
    ofstream cout(".out");
#endif // HOME
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, i, q;
    cin >> n >> q;
    for(i = 1; i <= n; i++){
        char c;
        cin >> c;
        a[i] = c - '0';
    }
    for(i = 1; i <= q; i++){
        cin >> s[i];
        cin >> qa[i];
        if(s[i][0] == 'q'){
            cin >> qb[i];
            qb[i]--;
            cout << total[qa[i]] + (i - lst[qa[i]]) * (a[qa[i]] == 1) << "\n";
        }else{
            a[qa[i]] ^= 1;
            if(a[qa[i]] == 0){
                total[qa[i]] += (i - lst[qa[i]]);
            }
            lst[qa[i]] = i;
        }
    }
    return 0;
}
#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...