# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1202298 | tegshzaya | Street Lamps (APIO19_street_lamps) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define endl "\n"
using namespace std;
ll n,m,o,p,ch[1005],c[1005],aa[1005];
string s,a;
int main(){
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
cin>>n>>m>>s;
for(ll i=1;i<=m;i++){
cin>>m;
if(m[0]=='q'){
cin>>o>>p;
if(s[o-1]=='1'){cout<<i-aa[o]+c[o]<<endl;}
else{cout<<c[o]<<endl;}
}
else{
cin>>o;
ch[i]=o;
if(s[o-1]=='0'){
aa[o]=i;
s[o-1]='1';
}
else{
c[o]+=i-aa[o];
s[o-1]='0';
}
}
}
}