Submission #1152566

#TimeUsernameProblemLanguageResultExecution timeMemory
1152566thelegendary08Zagrade (COI20_zagrade)C++17
0 / 100
471 ms420 KiB
#include<bits/stdc++.h>
#define f0r(i,n) for(int i = 0; i<n; i++)
#define pb push_back
#define vi vector<long long int>
#define ll long long int
#define mp make_pair
#define pii pair<ll,ll>
#define FOR(i, k, n) for(int i = k; i<n; i++)
using namespace std;
bool ask(int a, int b){
	cout<<'?'<<' '<<a+1<<' '<<b+1<<endl;
	int x;
	cin>>x;
	return x;
}
int main(){
	int n,q;
	cin>>n>>q;
	vi ans(n,-1);
	/*
	ans[0] = 0;
	stack<int>opens;
	opens.push(0);
	FOR(i, 1, n){
		if(opens.empty()){
			ans[i] = 0;
			opens.push(i);
		}
		else{
			bool x = ask(opens.top(), i);
			if(x){
				ans[i] = 1;
				opens.pop();
			}
			else{
				ans[i] = 0;
				opens.push(i);
			}
		}
	}
	*/
	for(int i = 2; i<=n; i+=2){
		f0r(j, n-i+1){
			bool b= ask(j, j+i-1);
			if(b){
				ans[j] = 0;
				ans[j+i-1] = 1;
				//cout<<j<<' '<<j+i<<'\n';
			}
		}
	}
	int cnt = 0;
	f0r(i,n){
		if(ans[i] == -1){
			cnt++;
		}
	}
	int ct = 0;
	f0r(i,n){
		if(ans[i] == -1){
			if(ct < cnt/2){
				ans[i] = 1;
			}
			else ans[i] = 0;
			ct++;
		}
	}
	cout<<'!'<<' ';
	f0r(i,n){
		if(ans[i])cout<<')';
		else cout<<'(';
	}
	cout<<endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...