Submission #371143

# Submission time Handle Problem Language Result Execution time Memory
371143 2021-02-25T22:56:17 Z Iwanttobreakfree Street Lamps (APIO19_street_lamps) C++
0 / 100
81 ms 672 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 81 ms 672 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 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 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 -