#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,q;
cin>>n>>q;
char s[n+5],cur[n+5];
for(ll i=1;i<=n;i++){
cin>>s[i];
}
vector<pair<ll,ll>>que(q);
for(ll i=0;i<q;i++){
string t;
cin>>t;
if(t=="toggle"){
ll j;
cin>>j;
que[i]={j,-1};
}
else{
ll a,b;
cin>>a>>b;
que[i]={a,b};
ll ans=0;
for(ll j=1;j<=n;j++){
cur[j]=s[j];
}
for(ll j=0;j<=i;j++){
bool ok=true;
for(ll k=a;k<b;k++){
if(cur[k]=='0'){
ok=false;
break;
}
}
if(ok){
ans++;
}
if(que[j].ss==-1){
ll p=que[j].ff;
if(cur[p]=='1') cur[p]='0';
else cur[p]='1';
}
}
cout<<ans<<"\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5038 ms |
6292 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
61 ms |
488 KB |
Output is correct |
5 |
Correct |
980 ms |
9936 KB |
Output is correct |
6 |
Execution timed out |
5022 ms |
7792 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Execution timed out |
5084 ms |
7576 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Execution timed out |
5038 ms |
6292 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |