Submission #411965

# Submission time Handle Problem Language Result Execution time Memory
411965 2021-05-26T11:14:40 Z 최서현(#7464) Zagrade (COI20_zagrade) C++17
0 / 100
1 ms 200 KB
#include <iostream>
#include <string>

using namespace std;

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

    int L[n + 2], R[n + 2];
    for(int i = 0; i <= n + 1; ++i) L[i] = i - 1, R[i] = i + 1;
    string ans(n, ' ');

    int cnt = n;

    while(1)
    {
        bool flag = false;

        int pt = R[0];
        int pt1 = R[pt];
        int pt2 = R[R[pt]];

        while(pt > 0)
        {
            cout << "? " << pt << ' ' << pt1 << endl; cout.flush();
            int t; cin >> t;
            if(t)
            {
                flag = true;
                L[R[pt]] = L[pt];
                R[L[pt]] = R[pt];
                L[R[pt1]] = L[pt1];
                R[L[pt1]] = R[pt1];
                ans[pt - 1] = '(';
                ans[pt1 - 1] = ')';
                cnt -= 2;
            }
            else break;
            pt1 = pt2;
            pt = L[pt1];
        }
        pt = pt2;

        if(!flag)
        {
            int cnt2 = 0;
            for(auto &c : ans) if(c == ' ')
            {
                if(cnt2 < cnt / 2) ++cnt2, c = ')';
                else c = '(';
            }
            break;
        }
    }

    cout << ans << endl; cout.flush();
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect query )(
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect query ))((
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect query ))((
2 Halted 0 ms 0 KB -