제출 #639977

#제출 시각아이디문제언어결과실행 시간메모리
639977TakeMeZagrade (COI20_zagrade)C++14
100 / 100
884 ms1460 KiB
/* Quick Note :
 * Jangan Mikir Lama - lama, sampahin dulu aja kalo OI
 * Always Try to reset
*/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 1e5 + 5;

ll n, q;
char ans[nax];

ll ask(ll l, ll r){
	cout << "? " << l << " " << r << endl;
	ll ret;
	cin >> ret;
	return ret;
}

int main(){ 
	cin >> n >> q;
	// reset
	for(ll i = 1; i <= n; i++){
		ans[i] = '*';
	}
	vector<ll> stk;
	stk.pb(1);
	ll half = 0;
	for(ll i = 2; i <= n; i++){
		if(stk.size() == 0){
			stk.pb(i);
			continue;
		}
		ll ls = stk.back();
		ll ret = ask(ls, i);
		if(ret == 0){
			stk.pb(i);
		}
		else{
			stk.pop_back();
			half++;
			ans[ls] = '(';
			ans[i] = ')';
		}
	}
	cout << "! ";
	for(ll i = 1; i <= n; i++){
		if(ans[i] == '*'){
			if(half != n / 2){
				half++;
				ans[i] = ')';
			}
			else{
				ans[i] = '(';
			}
		}
		cout << ans[i];
	}
	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...