답안 #1015848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015848 2024-07-06T22:18:25 Z Kryz Zagrade (COI20_zagrade) C++17
0 / 100
560 ms 2084 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){
        ll nw=st.top();
        cout<<"? "<<nw<<" "<<i<<endl;
        ll in;
        cin>>in;
        ffl;
        if(in==1){
            c[nw]='(';
            c[i]=')';
            st.pop();
        }
        else{
            st.push(i);
        }
    }
    REP(i,1,n){
        ll in=i;
        while(i<=n && c[i]=='0'){
            i++;
        }
        ll need=(i-in)/2;
        for(ll j=in;j<=i;j++){
            if(need){
                c[j]=')';
                need--;
            }
            else{
                c[j]='(';
            }
        }
    }
    cout<<"! ";
    REP(i,1,n)cout<<c[i];
}
/*
 
 ))))((((()
 */
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 2. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 5 ms 448 KB Output is correct
3 Runtime error 1 ms 344 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 3. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 560 ms 2084 KB Output is correct
3 Runtime error 1 ms 600 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -