제출 #1134128

#제출 시각아이디문제언어결과실행 시간메모리
1134128lopkusZagrade (COI20_zagrade)C++20
0 / 100
1 ms1200 KiB
#include <bits/stdc++.h>

#define int long long

using namespace std;

int ask(int l, int r) {
    cout << "? " << l << " " << r;
    cout << endl;
    int x;
    cin >> x;
    return x;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    stack<int> s;
    s.push(1);
    vector<int> a(n + 1, - 1);
    a[1] = 1;
    for(int i = 2; i <= n; i++) {
        if(ask(s.top(), i)) {
            a[i] = 0;
            s.pop();
        }
        else {
            a[i] = 1;
            s.push(i);
        }
    }
    cout << "! ";
    for(int i = 1; i <= n; i++) {
        if(a[i]) {
            cout << "(";
        }
        else {
            cout << ")";
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...