#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main () {
    ios_base::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0); 
    int N, Q;
    cin >> N >> Q;
    auto ask = [&](int a, int b) -> int {
        assert(Q --);
        cout << "? " << a << " " << b << endl;
        int res;
        cin >> res;
        return res;
    };
    string S(N, ')');
    vector<int> st;
    for (int i = 1;i <= N;i ++) {
        if (st.size() == 0) {
            st.push_back(i);
        } else if (ask(st.back(), i) == 1) {
            S[i - 1] = ')';
            S[st.back() - 1] = '(';
            st.pop_back();
        } else {
            st.push_back(i);
        }
    }
    int l = 0, r = st.size() - 1;
    while (l < r) {
        S[st[l ++] - 1] = ')';
        S[st[r --] - 1] = '(';
    }
    assert(l > r);
    cout << "! " << S << endl;
}
| # | 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... |