#include<bits/stdc++.h>
using namespace std;
void PlayGround() {
int n, q;
cin>>n>>q;
vector<int>state(n);
for(int i=0; i<n; ++i) {
char c;
cin>>c;
state[i] = c-'0';
}
vector<int>op;
for(int i=0; i<q; ++i) {
string type;
cin>>type;
if(type=="toggle") {
int j;
cin>>j;
op.push_back(j-1);
} else {
op.push_back(-1);
int a, b;
cin>>a>>b;
--a, --b;
int len = b-a;
int cnt = 0;
for(int j=a; j<b; ++j) {
cnt += state[j];
}
int ans = 0;
vector<int>temp = state;
for(int j=0; j<=i; ++j) {
if(op[j]==-1) ans += len==cnt;
else {
temp[op[j]] ^= 1;
if(op[j]>=a && op[j]<b) cnt += temp[op[j]]?1:-1;
}
}
cout<<ans<<'\n';
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5055 ms |
1752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |