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 N 200010
#define INFLL 2000000000000000020
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> pll;
vector<ll>abre;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n,q,i=1;
string ans=" ";
bool ret;
cin >> n >> q;
for(i=1;i<=n;i++)
{
ans+="(";
}
i=1;
while(i<=n)
{
if(abre.empty())
{
abre.pb(i);
i++;
continue;
}
cout << "? " << abre.back() << " " << i << endl;
fflush(stdout);
cin >> ret;
if(ret)
{
ans[i]=')';
abre.pop_back();
}else
{
abre.pb(i);
}
i++;
}
cout << "!" << ans << endl;
fflush(stdout);
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... |