제출 #586085

#제출 시각아이디문제언어결과실행 시간메모리
586085JovanBZagrade (COI20_zagrade)C++17
100 / 100
826 ms1220 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

const int N = 100000;

int val[N+5];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, qrs;
    cin >> n >> qrs;
    stack <int> st;
    for(int i=1; i<=n; i++){
        if(st.size()){
            cout << "? " << st.top() << " " << i << endl;
            int x;
            cin >> x;
            if(x){
                val[st.top()] = 1;
                st.pop();
            }
            else st.push(i);
        }
        else st.push(i);
    }
    int x = st.size()/2;
    while(x){
        val[st.top()] = 1;
        st.pop();
        x--;
    }
    cout << "! ";
    for(int i=1; i<=n; i++){
        if(val[i]) cout << "(";
        else cout << ")";
    }
    cout << 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...