#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, b, a) for (int i = b; i >= a; --i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
const int MAXN = 2e5 + 10;
const int INF = 1e18 + 5;
const int MOD = 1e9 + 7;
int x[MAXN];
int query(int l, int r) {
int ans;
cout << "? " << l << " " << r << endl;
cin >> ans;
return ans;
}
int32_t main() {
int n,q;cin >> n >> q;
string pfx[n+10];
stack<int> lo;
rep(i,1,n) {
if (lo.empty()) {
pfx[i] = "(";
lo.push(i);
continue;
}
int x = query(lo.top(),i);
if (x == 1) {
pfx[i] = ")";
lo.pop();
} else {
pfx[i] = "(";
lo.push(i);
}
}
cout << "! ";
rep(i,1,n) cout << pfx[i];
cout << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |