Submission #920456

# Submission time Handle Problem Language Result Execution time Memory
920456 2024-02-02T14:57:17 Z zeta7532 Zagrade (COI20_zagrade) C++17
0 / 100
443 ms 2184 KB
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)

int main() {
    ll N,Q;
    cin >> N >> Q;
    vector<char> ans(N,'-');
    deque<ll> que;
    ll l=0;
    ans[0]='(';
    que.push_back(0);
    ll r=1;
    while(1){
        if(r>=N) break;
        cout << "?" << " " << l+1 << " " << r+1 << endl;
        ll q;
        cin >> q;
        if(q==0){
            ans[r]='(';
            que.push_back(r);
            l=r;
            r=l+1;
        }
        if(q==1){
            que.pop_back();
            ans[r]=')';
            if(que.empty()){
                l=r+1;
                if(r+1!=N) ans[r+1]='(';
                if(r+1!=N) que.push_back(r+1);
                r=l+1;
            }else{
                l=l-1;
                r=r+1;
            }
        }
    }
    cout << "!" << " ";
    rep(i,N) cout << ans[i];
    cout << endl;
    return 0;
}
# 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 Incorrect 3 ms 344 KB Mismatch at position 20. Expected ), found (
4 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 214 ms 508 KB Output is correct
3 Incorrect 443 ms 2184 KB Mismatch at position 23. Expected ), found (
4 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 -