#include<bits/stdc++.h>
using namespace std;
int List[300002];
int answer[300002];
bool Now[300002];
int main(){
int N,Q;
cin>>N>>Q;
for(int i=1;i<=N;i++){
char s;
cin>>s;
if(s-'0') List[i]=0;
else List[i]=-1;
Now[i]=s-'0';
}
for(int i=1;i<=Q;i++){
string s;
int a,b;
cin>>s;
if(s=="query"){
cin>>a>>b;
if(List[a]!=-1) cout<<answer[a]+i-List[a]<<"\n";
else cout<<answer[a]<<"\n";
}
else{
cin>>a;
if(Now[a]){
Now[a]=1-Now[a];
answer[a]+=i-List[a];
List[a]=-1;
}
else{
Now[a]=1-Now[a];
List[a]=i;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
410 ms |
4348 KB |
Output is correct |
2 |
Correct |
465 ms |
4696 KB |
Output is correct |
3 |
Correct |
432 ms |
5280 KB |
Output is correct |
4 |
Correct |
510 ms |
8760 KB |
Output is correct |
5 |
Correct |
522 ms |
7960 KB |
Output is correct |
6 |
Correct |
453 ms |
8496 KB |
Output is correct |
7 |
Correct |
712 ms |
8288 KB |
Output is correct |
8 |
Correct |
716 ms |
9664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |