Submission #1152366

#TimeUsernameProblemLanguageResultExecution timeMemory
1152366gelastropodZagrade (COI20_zagrade)C++20
71 / 100
230 ms844 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	int N, Q, x;
	cin >> N >> Q;
	stack<int> stk;
	stk.push(-1);
	stk.push(0);
	vector<bool> close(N, false);
	for (int i = 1; i < N; i++) {
		if (stk.top() == -1) {
			stk.push(i);
			continue;
		}
		cout << "? " << stk.top() + 1 << ' ' << i + 1 << endl;
		cin >> x;
		if (x) {
			close[i] = true;
			stk.pop();
		}
		else
			stk.push(i);
	}
	cout << "! ";
	for (auto i : close)
		cout << (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...