#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<long long,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1e15
#define MOD 1000000007
#define MX 200005
using namespace std;
void solve(){
int n,q; cin >> n >> q;
string s; cin >> s;
vi arr[q+1];
for(int i=0; i<=q; i++) arr[i]=vector<int>(n+1);
for(int i=1; i<=n; i++){
arr[1][i]=s[i-1]-'0';
}
for(int i=1; i<=q; i++){
string h; cin >> h;
if(i!=q)copy(arr[i].begin(), arr[i].end(), arr[i+1].begin());
if(h[0]=='t'){
int a; cin >> a;
arr[i+1][a]=1-arr[i+1][a];
}
else{
int l,r; cin >> l >> r;
int ans=0;
for(int j=1; j<=i; j++){
int ok=1;
for(int f=l; f<r; f++){
if(!arr[j][f]){
ok=0;
break;
}
}
if(ok){
ans++;
}
}
cout << ans << endl;
}
}
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
/*freopen("nondec.in","r",stdin);
freopen("nondec.out","w",stdout);*/
int t=1;
//cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5087 ms |
247416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
16476 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
8284 KB |
Output is correct |
2 |
Correct |
6 ms |
8280 KB |
Output is correct |
3 |
Correct |
7 ms |
8368 KB |
Output is correct |
4 |
Correct |
5 ms |
8284 KB |
Output is correct |
5 |
Runtime error |
183 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |