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 N=1e5+5;
char C_[N];
int n_,q_,x_,pr_[N],nx_[N];
int main () {
cin>>n_>>q_; // ;(((((((((((((((((((((((((((((( qqqqqqq
for (int i=1; i<=n_+3; i++)
nx_[i]=i+1,pr_[i]=i-1,C_[i]='.';
int l_=1,r_=2,L_=l_,R_=r_,ans_=n_/2;
while (1<=L_ && L_<=n_ && 1<=R_ && R_<=n_) {
l_=L_,r_=R_;
nx_[l_]=r_;
pr_[r_]=l_;
cout<<"? "<<l_<<" "<<r_<<endl;
cin>>x_;
if (x_) {
--ans_;
C_[l_]='(',C_[r_]=')';
if (1<=pr_[l_]) L_=pr_[l_],R_=nx_[r_];
else L_=nx_[r_],R_=nx_[nx_[r_]],pr_[L_]=0;
}
else L_=nx_[l_],R_=nx_[r_],pr_[L_]=l_;
}
for (int i=1; i<=n_; i++)
if (C_[i]=='.') {
if (ans_>0)
C_[i]=')',--ans_;
else
C_[i]='(';
}
cout<<"! ";
for (int i=1; i<=n_; i++)
cout<<C_[i];
cout<<endl;
}
Compilation message (stderr)
zagrade.cpp: In function 'int main()':
zagrade.cpp:40:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
40 | for (int i=1; i<=n_; i++)
| ^~~
zagrade.cpp:42:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
42 | cout<<endl;
| ^~~~
# | 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... |