# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
838245 | manizare | Street Lamps (APIO19_street_lamps) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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" ;
}
}
}
/*
*/