# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780621 | devariaota | Zagrade (COI20_zagrade) | C++17 | 1 ms | 336 KiB |
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;
typedef long long ll;
ll n,q;
char ans[100005];
int main(){
cin>>n>>q;
for (int i=1;i<=100005;i++) ans[i]=' ';
ans[1]='('; ans[n]=')';
ll lo=2,hi=n-1;
while(lo<=hi){
cout<<">>> ? "<<lo-1<<" "<<lo<<endl;
fflush(stdout);
ll x;
cin>>x;
if (x==1) {
if (ans[lo]==' ')
ans[lo]=')';
if (ans[lo+1]==' ')
ans[lo+1]='(';
lo+=2;
}
else{
if (ans[lo]==' ')
ans[lo]='(';
lo+=1;
}
cout<<">>> ? "<<hi<<" "<<hi+1<<endl;
cin>>x;
fflush(stdout);
if (x==1){
if (ans[hi]==' ')
ans[hi]='(';
if (ans[hi-1]==' ')
ans[hi-1]=')';
hi-=2;
}
else{
if (ans[hi]==' ')
ans[hi]=')';
hi-=1;
}
}
cout<<">>> ! ";
for (int i=1;i<=n;i++){
cout<<ans[i];
}
}
Compilation message (stderr)
# | 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... |