Submission #371140

#TimeUsernameProblemLanguageResultExecution timeMemory
371140IwanttobreakfreeStreet Lamps (APIO19_street_lamps)C++17
0 / 100
5061 ms6956 KiB
#include <iostream> #include <vector> using namespace std; int main(){ 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; mini=min(mini,i-lastupdate[j]); } if(posible)cout<<mini<<'\n'; else cout<<0<<'\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...