Submission #798745

# Submission time Handle Problem Language Result Execution time Memory
798745 2023-07-31T03:02:32 Z exodus_ Zagrade (COI20_zagrade) C++14
0 / 100
0 ms 208 KB
#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 time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect query ()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect query )(
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect query (())
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect query ))((
2 Halted 0 ms 0 KB -