제출 #863632

#제출 시각아이디문제언어결과실행 시간메모리
863632RifalZagrade (COI20_zagrade)C++14
71 / 100
478 ms1324 KiB
#include <bits/stdc++.h>
#include <fstream>
//#define endl '\n'
#define mod 1000000007
#define INF 900000000
//#define cin fin
//#define cout fout
//#define fi first
//#define se second
using namespace std;
//ofstream fout("intel.out");
//ifstream fin("intel.in");

int main()
{
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    int n, q; cin >> n >> q; string ans; stack<int> st;
    for(int i = 1; i <= n; i++) {
        if(st.empty()) {
            st.push(i);
            ans.push_back('(');
        }
        else {
            cout << '?' << ' '  << st.top() << ' ' << i << endl;
            int x; cin >> x; 
            if(x == 1) {
                st.pop();
                ans.push_back(')');
            }
            else {
                st.push(i);
                ans.push_back('(');
            }
        }
    }
    cout << '!' << ' ' << ans << 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...