답안 #920468

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920468 2024-02-02T15:08:41 Z zeta7532 Zagrade (COI20_zagrade) C++17
71 / 100
568 ms 5432 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,'-');
    ll l=0;
    ans[0]='(';
    ll r=1;
    set<ll> s;
    rep(i,N) s.insert(i);
    while(1){
        if(r>=N) break;
        cout << "?" << " " << l+1 << " " << r+1 << endl;
        ll q;
        cin >> q;
        if(q==0){
            ans[r]='(';
            l=r;
            r=l+1;
        }
        if(q==1){
            s.erase(l);
            s.erase(r);
            ans[r]=')';
            if(s.size()==0) break;
            if((*s.begin())>l){
                l=r+1;
                if(r+1!=N) ans[r+1]='(';
                r=l+1;
            }else{
                auto it=s.upper_bound(l);
                it--;
                l=*it;
                r=r+1;
            }
        }    
    }
    cout << "!" << " ";
    rep(i,N) cout << ans[i];
    cout << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 255 ms 5432 KB Output is correct
3 Correct 556 ms 5208 KB Output is correct
4 Correct 565 ms 4980 KB Output is correct
5 Correct 561 ms 5204 KB Output is correct
6 Correct 552 ms 5208 KB Output is correct
7 Correct 568 ms 5208 KB Output is correct
8 Correct 554 ms 5208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 540 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -