제출 #798745

#제출 시각아이디문제언어결과실행 시간메모리
798745exodus_Zagrade (COI20_zagrade)C++14
0 / 100
0 ms208 KiB
#include<bits/stdc++.h>
using namespace std;
char result[100001];
int main() {
    int N, Q;
    stack<int>tunggu;
    cin >> N >> Q;
    int half=N/2;
    bool apa;
    for (int i=1; i<=N; i++) {
        if(tunggu.empty()==true) {
            tunggu.push(i);
        } else {
            cout << "? " << tunggu.top() << " " << i << endl;
            cin >> apa;
            if(apa==true) {
                result[tunggu.top()]='(';
                result[i]=')';
                half--;
                tunggu.pop();
            } else {
                tunggu.push(i);
            }
        }
    }
    while(!tunggu.empty()) {
        if(half!=0) {
            result[tunggu.top()]='(';
            half--;
            tunggu.pop();
        } else {
            result[tunggu.top()]=')';
            tunggu.pop();
        }
    }
    for (int i=1; i<=N; i++) {
        cout << result[i];
    }
    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...