Submission #442602

# Submission time Handle Problem Language Result Execution time Memory
442602 2021-07-08T09:11:43 Z BornaCizmarevic Zagrade (COI20_zagrade) C++14
100 / 100
1061 ms 1520 KB
#include <bits/stdc++.h>

using namespace std;

int main (){
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,q;
	cin>>n;
	cin>>q;
	int niz[n];
	memset(niz,0,sizeof niz);
	char s[n];
	int p=1;
	vector <int> v;
	v.push_back(1);
	for (int i=1;i<n;i++){
		p=v[v.size()-1];
		cout<<"? "<<p<<" "<<i+1<<endl;
		bool ans;
		cin>>ans;
		if (ans==0){
			v.push_back(i+1);
		}
		if (ans==1){
			s[i]=')';
			s[p-1]='(';
			niz[i]=1;
			niz[p-1]=1;
			v.pop_back();
			if (v.size()==0 and i<n-1){
				v.push_back(i+2);
				i++;
			}
		}
	}
	int br=0,nb=0;
	for (int i=0;i<n;i++){
		if (niz[i]!=1){
			br++;;
		}
	}
	cout<<"! ";
	for (int i=0;i<n;i++){
		if (niz[i]!=1 and nb<br/2){
			cout<<')';
			nb++;
		}
		else if (niz[i]!=1 and nb>=br/2){
			cout<<'(';
		}
		else {
			cout<<s[i];
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 6 ms 200 KB Output is correct
3 Correct 11 ms 200 KB Output is correct
4 Correct 12 ms 200 KB Output is correct
5 Correct 12 ms 200 KB Output is correct
6 Correct 15 ms 200 KB Output is correct
7 Correct 16 ms 200 KB Output is correct
8 Correct 11 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 8 ms 256 KB Output is correct
3 Correct 11 ms 200 KB Output is correct
4 Correct 12 ms 200 KB Output is correct
5 Correct 11 ms 312 KB Output is correct
6 Correct 9 ms 200 KB Output is correct
7 Correct 9 ms 200 KB Output is correct
8 Correct 13 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 358 ms 780 KB Output is correct
3 Correct 1018 ms 776 KB Output is correct
4 Correct 900 ms 776 KB Output is correct
5 Correct 856 ms 836 KB Output is correct
6 Correct 868 ms 772 KB Output is correct
7 Correct 1061 ms 1444 KB Output is correct
8 Correct 871 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 939 ms 1520 KB Output is correct
3 Correct 949 ms 1200 KB Output is correct
4 Correct 957 ms 1504 KB Output is correct
5 Correct 804 ms 1216 KB Output is correct
6 Correct 1020 ms 1280 KB Output is correct
7 Correct 861 ms 1144 KB Output is correct
8 Correct 803 ms 776 KB Output is correct