Submission #371142

# Submission time Handle Problem Language Result Execution time Memory
371142 2021-02-25T22:51:03 Z Iwanttobreakfree Street Lamps (APIO19_street_lamps) C++17
0 / 100
5000 ms 2756 KB
#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
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1206 ms 2668 KB Output is correct
6 Execution timed out 5076 ms 2756 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -