# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
838245 | 2023-08-26T12:00:07 Z | manizare | Street Lamps (APIO19_street_lamps) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(a) a.begin(),a.end() #define pii pair<int,int> using namespace std ; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 1000 + 10 , inf = 1e9+10 ; int pre[maxn][maxn] ; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >>n >> q; string s; cin >> s; s= "0" + s; for(int i = 1; i <= q ; i++){ string a ; cin >> a; if(a[0] == 't'){ int x; cin >> x; if(s[x] == '0')s[x] = '1' ; else s[x] = '0' ; } for(int j = 1; j <= n; j++){ pre[i][j] = pre[i][j] + (s[j] == '0') ; } if(a[0] == 'q'){ int r , l; cin >> l >> r ; int ans = 0 ; for(int j = 1; j <= i ;j++){ if(pre[j][r] == pre[j][l-1])ans ++ ; } cout << ans << "\n" ; } } } /* */