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;
const int M = 1e5 + 1;
char ans[M];
void solve(int a,int b)
{
if (a+1==b)
{
ans[a]='(';
ans[b]=')';
return;
}
cout<<"? "<<a+1<<' '<<b-1<<endl;
bool v;
cin>>v;
if (v)
{
ans[a]='(';
ans[b]=')';
solve(a+1,b-1);
return;
}
for (int i=a+1;i<b;i++)
{
cout<<"? "<<a<<' '<<i<<endl;
cin>>v;
if (v)
{
solve(a,i);
solve(i+1,b);
return;
}
}
}
int main()
{
int n,q;
cin>>n>>q;
solve(1,n);
cout<<"! ";
for (int i=1;i<=n;i++)
cout<<ans[i];
cout<<endl;
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... |