Submission #1004067

# Submission time Handle Problem Language Result Execution time Memory
1004067 2024-06-21T04:14:17 Z vjudge1 Zagrade (COI20_zagrade) C++17
100 / 100
606 ms 1752 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, q;
    cin >> n >> q;

    vector<int> vec;
    vec.push_back(1);

    char ans[n + 1];
    for (int i = 2; i <= n; i ++){
        if (vec.size() == 0){
            vec.push_back(i);
            continue;
        }

        int l = vec.back();
        cout << "? " << l << " " << i << endl;
        
        bool regular;
        cin >> regular;

        if (regular){
            ans[l] = '(';
            ans[i] = ')';
            vec.pop_back();
            continue;
        }

        vec.push_back(i);
    }

    int x = vec.size();
    x /= 2;

    for (int i = 0; i < x; i ++){
        int last = vec.back();
        ans[last] = '(';
        vec.pop_back();
    }

    for (int i = 0; i < x; i ++){
        int last = vec.back();
        ans[last] = ')';
        vec.pop_back();
    }

    cout << "! ";
    for (int i = 1; i <= n; i ++)
        cout << ans[i];
    cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 6 ms 436 KB Output is correct
3 Correct 4 ms 436 KB Output is correct
4 Correct 6 ms 436 KB Output is correct
5 Correct 9 ms 432 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 259 ms 424 KB Output is correct
3 Correct 551 ms 344 KB Output is correct
4 Correct 578 ms 344 KB Output is correct
5 Correct 562 ms 344 KB Output is correct
6 Correct 567 ms 344 KB Output is correct
7 Correct 523 ms 1012 KB Output is correct
8 Correct 432 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 487 ms 1488 KB Output is correct
3 Correct 531 ms 1076 KB Output is correct
4 Correct 548 ms 1060 KB Output is correct
5 Correct 526 ms 1080 KB Output is correct
6 Correct 553 ms 1360 KB Output is correct
7 Correct 606 ms 1752 KB Output is correct
8 Correct 565 ms 508 KB Output is correct