Submission #1154232

#TimeUsernameProblemLanguageResultExecution timeMemory
1154232huoiZagrade (COI20_zagrade)C++17
0 / 100
229 ms652 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define INF 1e18

void solve() {
    int n, q;
    cin >> n >> q;

    string ans = "(";
    stack<char> st;
    st.push('(');
    for (int i = 1; i < n; i++) {
        cout << "? " << i << " " << i + 1 << endl;
        bool valid; cin >> valid;
        if (valid) {
            ans += ")";
            st.pop();
        } else {
            if (ans[i - 1] == '(' || st.empty()) {
                ans += "(";
                st.push('(');
            } else {
                ans += ")";
                st.pop();
            }
        }
    }
    cout << "! " << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...