Submission #1015860

# Submission time Handle Problem Language Result Execution time Memory
1015860 2024-07-06T22:37:30 Z Kryz Zagrade (COI20_zagrade) C++17
100 / 100
630 ms 2668 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<<endl;
        ffl;
        ll in;
        cin>>in;
        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];
    cout<<endl;
    ffl;
}
/*
 
()(()))()(
 */
# 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 Correct 6 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 8 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 6 ms 436 KB Output is correct
5 Correct 5 ms 440 KB Output is correct
6 Correct 6 ms 700 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 259 ms 344 KB Output is correct
3 Correct 598 ms 344 KB Output is correct
4 Correct 630 ms 344 KB Output is correct
5 Correct 603 ms 344 KB Output is correct
6 Correct 570 ms 344 KB Output is correct
7 Correct 583 ms 1620 KB Output is correct
8 Correct 585 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 599 ms 2668 KB Output is correct
3 Correct 570 ms 1392 KB Output is correct
4 Correct 588 ms 1892 KB Output is correct
5 Correct 552 ms 1404 KB Output is correct
6 Correct 555 ms 1800 KB Output is correct
7 Correct 583 ms 1168 KB Output is correct
8 Correct 603 ms 516 KB Output is correct