Submission #381471

#TimeUsernameProblemLanguageResultExecution timeMemory
381471topovikZagrade (COI20_zagrade)C++14
71 / 100
932 ms1004 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define len(x) x.size()
#define debug(x) cout << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef long double ld;

const ll N = 1e6 + 100;
const ll oo = 1e9 + 7;
const ll k = 10;

int main()
{
    int n, q;
    cin >> n >> q;
    stack <int> st;
    string ans;
    for (int i = 0; i < n; i++)
    {
        if (st.size() == 0)
        {
            ans += "(";
            st.push(i);
            continue;
        }
        cout << "? " << st.top() + 1 << " " << i + 1 << endl;
        bool g;
        cin >> g;
        if (g)
        {
            st.pop();
            ans += ")";
        }
        else
        {
            st.push(i);
            ans += "(";
        }
    }
    cout << "! " << ans << 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...