Submission #1214532

#TimeUsernameProblemLanguageResultExecution timeMemory
1214532omarrrrZagrade (COI20_zagrade)C++20
71 / 100
236 ms1068 KiB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define mpr make_pair

const ll N=2e6 + 10 , mod=1e9 + 7, inf=1e18;

using namespace std;

ll n,m,k,q,c,x,y;
ll t[N];
vector<bool>vis(false,1000);

int main(){
     ios_base::sync_with_stdio (0); cin.tie(0),cout.tie(0);

//    freopen("dining.in","r",stdin);
//    freopen("dining.out","w",stdout);




    ll T=1;
    //cin>>T;
    while(T--){
        cin>>n>>q;
        string ch="";

        ll l=1,r=2,tot=1,y=0;

        priority_queue<ll>pq;
        vector<char>v(n+5,'.');
        v[1]='(';
        while(tot<n){
            cout<<"? "<<l<<" "<<r<<endl;
            cin>>x;
            if(x==1){
                v[r]=')';
                tot++;
                if(!pq.empty()){
                    l=pq.top();
                    pq.pop();
                }else{
                    v[r+1]='(';
                    l=r+1;
                    r++;
                    tot++;
                }
            }else{
                v[l]='(';
                pq.push(l);
                tot++;
                l=r;
            }
          //  cout<<tot<<" "<<pq.size()<<"\n";
            r++;
            y++;
        }
        cout<<"! ";
        for(ll i=1;i<=n;i++){
            cout<<(v[i]!='.' ? v[i]:'(');
        }
        cout<<endl;





    }


    return 0;
}

/*
12 11
(()(())(()((





*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...