Submission #1015872

# Submission time Handle Problem Language Result Execution time Memory
1015872 2024-07-07T00:29:20 Z 12345678 Zagrade (COI20_zagrade) C++17
14 / 100
689 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e3+5;

int n, res[nx], x, q;

int query(int l, int r)
{
    cout<<"? "<<l<<' '<<r<<'\n';
    fflush(stdout);
    cin>>x;
    return x;
}
void solve(int l, int r)
{
    if (r<l) return;
    if (r==l+1) return res[l]=1, void();
    for (int i=l+1; i<r; i++) if (((i-l+1)%2)==0&&query(l, i)) return solve(l, i), solve(i+1, r), void();
    res[l]=1;
    solve(l+1, r-1);
}

int main()
{
    cin>>n>>q;
    solve(1, n);
    cout<<"! ";
    for (int i=1; i<=n;i ++) cout<<(res[i]?'(':')');
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 21 ms 344 KB Output is correct
4 Correct 27 ms 344 KB Output is correct
5 Correct 53 ms 344 KB Output is correct
6 Correct 56 ms 344 KB Output is correct
7 Correct 689 ms 344 KB Output is correct
8 Correct 45 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 4 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -