#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define N 300010
ll n,q;
ll tim[N],pnt[N],flag[N];
int main(){
cin>>n>>q;
string s;
cin>>s;
rep(i,n){
tim[i]=0,pnt[i]=0,flag[i]=(s[i]=='1');
}
for(int i=1;i<=q;i++){
string typ;
cin>>typ;
if(typ=="toggle"){
ll x; cin>>x;
x--;
pnt[x]+=flag[x]*(i-tim[x]);
tim[x]=i;
flag[x]^=1;
}
else{
ll x,b; cin>>x>>b;
x--;
pnt[x]+=flag[x]*(i-tim[x]);
tim[x]=i;
cout<<pnt[x]<<endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
561 ms |
1272 KB |
Output is correct |
2 |
Correct |
596 ms |
4856 KB |
Output is correct |
3 |
Correct |
602 ms |
5496 KB |
Output is correct |
4 |
Correct |
720 ms |
13744 KB |
Output is correct |
5 |
Correct |
796 ms |
14144 KB |
Output is correct |
6 |
Correct |
663 ms |
13460 KB |
Output is correct |
7 |
Correct |
1156 ms |
14324 KB |
Output is correct |
8 |
Correct |
1115 ms |
15768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |