#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';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
545 ms |
4104 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
3 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
492 KB |
Output is correct |
5 |
Correct |
584 ms |
6956 KB |
Output is correct |
6 |
Execution timed out |
5061 ms |
5640 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
364 KB |
Output is correct |
2 |
Incorrect |
4 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |