This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n,q;
cin>>n>>q;
stack<int>isi;
char jwb[n+1];
for(int d=1;d<=n;d++){
if(isi.empty()){
isi.push(d);
jwb[d]='(';
}
else{
cout<<"? "<<isi.top()<<" "<<d<<endl;
int w;
cin>>w;
if(w==0){
isi.push(d);
jwb[d]='(';
}
else{
isi.pop();
jwb[d]=')';
}
}
}
int ganti=isi.size()/2;
while(!isi.empty()){
if(ganti==0){
jwb[isi.top()]='(';
}
else{
ganti--;
}
isi.pop();
}
cout<<"! ";
for(int d=1;d<=n;d++){
cout<<jwb[d];
}
}
# | 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... |