#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];
int ans = 0;
int cl = 1, cr = 2;
rep(i,1,n-1) {
int x = query(cl,cr);
if (x == 1) {
pfx[cr] = ")";
pfx[cl] = "(";
cr++;
cl--;
if (cr > n) break;
if (cl < 1) {
cl = cr;
cr++;
pfx[cl] = "(";
}
} else {
pfx[cr] = "(";
cl=cr;
cr++;
}
}
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... |