#include <iostream>
#include <vector>
using namespace std;
typedef pair<int,int> pii;
bool sub1=false;
bool sub2=true;
int N,Q;
char c;
string s;
int A[300005],B[300005];
bool P[300005];
bool T[105][105];
vector<pii> V[300005];
int main(){
cin>>N>>Q;
for(int i=0;i<N;i++){
cin>>c;
P[i]=(c=='1');
T[0][i]=P[i];
}
for(int i=0;i<Q;i++){
cin>>s;
if(s=="query"){
cin>>A[i]>>B[i];
A[i]--;
B[i]--;
if(B[i]-A[i]!=1)
sub2=false;
}
else{
cin>>A[i];
A[i]--;
B[i]=-1;
}
}
sub2=true;
if(sub1 and N<=100 and Q<=100){
for(int i=0;i<Q;i++){
if(B[i]==-1)
T[i+1][A[i]]=true;
else{
int ans=0;
for(int k=0;k<i+1;k++){
bool flag=true;
for(int j=A[i];j<B[i];j++)
flag&=T[k][j];
ans+=flag;
}
cout<<ans<<"\n";
}
for(int j=0;j<N;j++)
T[i+1][j]^=T[i][j];
}
}
else if(sub2){
for(int i=0;i<N;i++)
V[i].push_back({0,0});
for(int i=0;i<Q;i++){
if(B[i]==-1){
if(P[A[i]])
V[A[i]].push_back({i+1,V[A[i]].back().second+i+1-V[A[i]].back().first});
else
V[A[i]].push_back({i+1,V[A[i]].back().second});
P[A[i]]=!P[A[i]];
}
else{
if(P[A[i]])
cout<<V[A[i]].back().second+i+1-V[A[i]].back().first<<"\n";
else
cout<<V[A[i]].back().second<<"\n";
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
330 ms |
12536 KB |
Output is correct |
2 |
Correct |
349 ms |
12632 KB |
Output is correct |
3 |
Correct |
407 ms |
12912 KB |
Output is correct |
4 |
Incorrect |
622 ms |
21360 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
7416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
7416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |