This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
int main(){
cin.tie(NULL);
ios::sync_with_stdio(false);
string str;
int n,q,a,b;
char c;
cin>>n>>q;
vector<int> lamp(n);
vector<int> lastupdate(n,0);
for(int i=0;i<n;i++){
cin>>c;
if(c=='0')lamp[i]=0;
else lamp[i]=1;
}
for(int i=1;i<=q;i++){
cin>>str;
if(str=="toggle"){
cin>>a;
a--;
lamp[a]=1-lamp[a];
lastupdate[a]=i;
}
else{
cin>>a>>b;
a--;
b--;
int mini=1e9;
bool posible=true;
for(int j=a;j<=b;j++){
if(lamp[j]==0)posible=false;
else mini=min(mini,i-lastupdate[j]);
}
if(posible)cout<<mini<<'\n';
else cout<<0<<'\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |