#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'
bool ask(int aa,int bb){
cout<<"? "<<aa+1<<" "<<bb+1<<endl;
int x;
cin>>x;
return x;
}
int ans[100001];
int aa[1001][1001];
/*void solve(int l,int r){
for(int i=l+1;i<=r;i+=2){
if(ask(ind,i)){
ans[i]=1;
if(i>l+1){
solve(l+1,i-1);
}
if(i<r-1){
solve(i+1,r-1);
}
break;
}
}
}*/
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,q;
cin>>n>>q;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j+=2){
aa[i][j]=ask(i,j);
}
}
set<int> ind;
for(int i=0;i<n;i++){
ind.insert(i);
}
while(ind.size()){
vector<int> ss;
for(auto j:ind){
ss.pb(j);
}
int st=0;
for(int i=0;i<ss.size()-1;i++){
if(aa[ss[i]][ss[i+1]]){
ans[ss[i+1]]=1;
ind.erase(ss[i]);
ind.erase(ss[i+1]);
st=1;
break;
}
}
if(st){
continue;
}
for(auto j:ss){
ans[ss[i]]=1;
}
for(int i=ss.size()/2;i<ss.size();i++){
ans[ss[i]]=0;
}
break;
}
// solve(0,n-1);
cout<<"! ";
for(int i=0;i<n;i++){
if(ans[i]==0){
cout<<'(';
}
else{
cout<<")";
}
}
cout<<endl;
return 0;
}
Compilation message
zagrade.cpp: In function 'int main()':
zagrade.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i=0;i<ss.size()-1;i++){
| ~^~~~~~~~~~~~
zagrade.cpp:67:11: error: 'i' was not declared in this scope
67 | ans[ss[i]]=1;
| ^
zagrade.cpp:66:12: warning: unused variable 'j' [-Wunused-variable]
66 | for(auto j:ss){
| ^
zagrade.cpp:69:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(int i=ss.size()/2;i<ss.size();i++){
| ~^~~~~~~~~~