Submission #798748

# Submission time Handle Problem Language Result Execution time Memory
798748 2023-07-31T03:03:45 Z exodus_ Zagrade (COI20_zagrade) C++14
100 / 100
859 ms 692 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;
            cout << flush;
            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();
        }
    }
    cout << "! ";
    for (int i=1; i<=N; i++) {
        cout << result[i];
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 5 ms 216 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 7 ms 304 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 9 ms 304 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 354 ms 416 KB Output is correct
3 Correct 558 ms 376 KB Output is correct
4 Correct 460 ms 328 KB Output is correct
5 Correct 759 ms 372 KB Output is correct
6 Correct 586 ms 300 KB Output is correct
7 Correct 760 ms 668 KB Output is correct
8 Correct 852 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 859 ms 692 KB Output is correct
3 Correct 493 ms 556 KB Output is correct
4 Correct 606 ms 584 KB Output is correct
5 Correct 814 ms 412 KB Output is correct
6 Correct 718 ms 496 KB Output is correct
7 Correct 738 ms 528 KB Output is correct
8 Correct 744 ms 436 KB Output is correct