Submission #639977

# Submission time Handle Problem Language Result Execution time Memory
639977 2022-09-13T04:41:53 Z TakeMe Zagrade (COI20_zagrade) C++14
100 / 100
884 ms 1460 KB
/* 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 time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 8 ms 308 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 13 ms 312 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 9 ms 312 KB Output is correct
7 Correct 9 ms 308 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 432 ms 336 KB Output is correct
3 Correct 884 ms 336 KB Output is correct
4 Correct 469 ms 336 KB Output is correct
5 Correct 668 ms 380 KB Output is correct
6 Correct 827 ms 384 KB Output is correct
7 Correct 754 ms 1096 KB Output is correct
8 Correct 743 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 842 ms 1460 KB Output is correct
3 Correct 668 ms 764 KB Output is correct
4 Correct 860 ms 1092 KB Output is correct
5 Correct 668 ms 740 KB Output is correct
6 Correct 833 ms 1004 KB Output is correct
7 Correct 879 ms 828 KB Output is correct
8 Correct 877 ms 388 KB Output is correct