Submission #1015850

# Submission time Handle Problem Language Result Execution time Memory
1015850 2024-07-06T22:24:24 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){
        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);
        }
    }
    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];
}
/*
 
 ))))((((()
 */
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -