Submission #641571

# Submission time Handle Problem Language Result Execution time Memory
641571 2022-09-17T04:23:22 Z kebine Zagrade (COI20_zagrade) C++17
0 / 100
774 ms 3756 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() 
{
    cin.tie(0); ios_base::sync_with_stdio(0);

    int n, q;
    cin >> n >> q;

    vector<int> ans(n, -1), v;
    set<int> s;
    s.insert(0);
    for(int i = 1; i < n; i++) {
        int l = *s.rbegin(), r = i;
        while(1) {
            if(l >= 0 && r < n) {
                cout << "? " << l + 1 << " " << r + 1 << endl;
                int x; cin >> x;
                if(x) {
                    ans[l] = 1;
                    ans[r] = 0;
                    l--, r++;
                } else {
                    break;
                }
            } else {
                break;
            }
        }
        i = r;
        if(ans[i] == -1) s.insert(i);
    }

    cout << "! ";
    for(int i = 0; i < n; i++) {
        if(ans[i]) cout << '('; 
        else cout << ')';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 7 ms 336 KB Output is correct
3 Incorrect 6 ms 332 KB Mismatch at position 20. Expected ), found (
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 673 ms 3232 KB Output is correct
3 Incorrect 774 ms 3756 KB Mismatch at position 23. Expected ), found (
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -