#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main(){
int n, q, check;
string ans;
vector<ii> paired;
cin>>n>>q;
int ptr=1;
int counter=0;
stack<int> singlepos;
while(ptr<n+1){
if(ptr==n){
ptr++;
continue;
}
cout<<"? "<<ptr<<' '<<ptr+1<<endl;
cin>>check;
if(check==0){
ans+='(';
singlepos.push(ptr);
++ptr;
}else{
ans+="()";
ptr+=2;
while(check==1){
if(singlepos.empty()) break;
cout<<"? "<<singlepos.top()<<' '<<ptr<<endl;
cin>>check;
if(check==1){
ans+=')';
singlepos.pop();
ptr++;
}
}
}
}
while(ans.length()<n){
ans+=')';
}
cout<<"! "<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |