#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=105;
int const mod=1e9+7;
int n,q;
string s;
int ans[N][N];
set<int> blocked;
int check(int a,int b){
if( (blocked.lower_bound(a))==blocked.end() || (*(blocked.lower_bound(a)))>=b)
return 1;
return 0;
}
void solve1(){
cin>>s;
for(int i=0;i<n;i++)
if(s[i]=='0')
blocked.insert(i);
while(q--){
for(int i=0;i<=n;i++)
for(int j=i;j<=n;j++)
ans[i][j]+=check(i,j);
string o;
cin>>o;
if(o=="toggle"){
int t;
cin>>t;
t--;
if(s[t]=='1'){
blocked.insert(t);
s[t]='0';
}
else{
blocked.erase(t);
s[t]='1';
}
}
else{
int a,b;
cin>>a>>b;
a--;b--;
cout<<ans[a][b]<<endl;
}
}
}
int main(){
cin>>n>>q;
if(n<=100 && q<=100)
solve1();
else{
return 0;
// solve2();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |