답안 #1015859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015859 2024-07-06T22:34:56 Z Kryz Zagrade (COI20_zagrade) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define sst string
#define pb push_back
#define maxco 100000+5
#define lld long double
#define cha ios_base::sync_with_stdio(false);
#define ffl cout.flush();
#define phi acos(-1)
#define mr make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define pqin priority_queue<ll,vector<ll>,greater<>>
#define pqpair priority_queue<pair<ll,ll> ,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define pqpair2 priority_queue<pair<pair<ll,ll>,pair<ll,ll>>,vector<pair<pi,pair<ll,ll>>>,greater<pair<pi,pair<ll,ll>>>>
#define INF 1000000009
#define MAXN 300006
#define pii pair<ll,ll>
#define mod 998244353

ll n,k;
ll b[MAXN],h[MAXN];
char c[MAXN];
int main(){
    cin>>n>>k;
    stack<ll> st;
    REP(i,1,n)c[i]='0';
    st.push(1);
    REP(i,2,n){
        if(st.size()==0){
            st.push(i);
            continue;
        }
        ll nw=st.top();
        
        cout<<"? "<<nw<<" "<<i;
        ffl;
        ll in;
        cin>>in;
        ffl;
        if(in==1){
            c[nw]='(';
            c[i]=')';
            st.pop();
        }
        else{
            st.push(i);
        }
    }
    vector <ll> vec;
    REP(i,1,n){
        if(c[i]=='0')vec.pb(i);
    }
    ll need=vec.size()/2;
    for(auto x : vec){
        if(need){
            c[x]=')';
            need--;
        }
        else{
            c[x]='(';
        }
    }
    cout<<"! ";
    REP(i,1,n)cout<<c[i];
}
/*
 
()(()))()(
 */
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -