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>
using namespace std;
const int mxn = 3e5+10;
int arr[mxn],pre[mxn],sum[mxn];
int N,Q;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>Q;
if(N>mxn||Q>mxn)return 0;
string s;
cin>>s;
s = "#"+s;
for(int i = 1;i<=N;i++){
arr[i] = s[i]-'0';
pre[i] = 0;
}
for(int i = 1;i<=Q;i++){
string tp;
cin>>tp;
if(tp[0] == 'q'){
int a,b;
cin>>a>>b;
cout<<sum[a]+arr[a]*(i-pre[a])<<'\n';
}
else{
int a;
cin>>a;
sum[a] += arr[a]*(i-pre[a]);
pre[a] = i;
arr[a] ^= 1;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |