제출 #706248

#제출 시각아이디문제언어결과실행 시간메모리
706248vjudge1Zagrade (COI20_zagrade)C++17
0 / 100
204 ms556 KiB
#include <bits/stdc++.h>
// #define endl '\n'
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int ll
typedef long long ll;
using namespace std;
const int N = 200000 + 10;
bool vis[N];
signed main() {
    FAST;
    int n, q;
    cin >> n >> q;
    stack<int> st;
    st.push(0);
    vis[0] = 1;
    for(int i = 1; i < n - 1; i++) {
        if(!st.size()) st.push(i);
        else {
            cout << "? " << st.top() + 1 << ' ' << i + 1 << endl;
            int x;
            cin >> x;
            if(x == 1) st.pop();
            else {
                st.push(i);
                vis[i] = 1;
            }
        }
    }
    string s = "";
    for(int i = 0; i < n; i++) {
        if(vis[i]) s += "(";
        else s += ")";
    }
    cout << "! " << s << endl;
    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...