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>
#define int long long
using namespace std;
int n;
bool ask(int x,int y){
if(x<=0 || y<=0 || x>n || y>n)
return false;
cout<<"examine"<<' '<<x<<' '<<y<<endl;
string s;
cin>>s;
if(s=="true")
return true;
return false;
}
int x,y;
main(){
cin>>n>>x>>y;
int xr=0;
int log=1;
int l=0,r=0;
while(true){
if(x+log>n){
l=x+(log/2);
r=n;
break;
}
if(!ask(x+log,y)){
r=x+log;
l=x+(log/2);
break;
}
log*=2;
}
while(r-l>1){
int mid=(l+r)/2;
if(ask(mid,y))
l=mid;
else r=mid;
}
if(ask(r,y))
xr=r;
else xr=l;
int xl=0;
log=1;
l=0; r=0;
while(true){
if(x-log<=0){
l=0;
r=x-(log/2);
break;
}
if(!ask(x-log,y)){
l=x-log;
r=x-(log/2);
break;
}
log*=2;
}
while(r-l>1){
int mid=(l+r)/2;
if(ask(mid,y))
r=mid;
else l=mid;
}
if(ask(l,y))
xl=l;
else xl=r;
int yn=0;
log=1;
l=0; r=0;
while(true){
if(y+log>n){
l=y+(log/2);
r=n;while(true){
if(x+log>n){
l=x+(log/2);
r=n;
break;
}
if(!ask(x+log,y)){
r=x+log;
l=x+(log/2);
break;
}
log*=2;
}
while(r-l>1){
int mid=(l+r)/2;
if(ask(mid,y))
l=mid;
else r=mid;
}
if(ask(r,y))
xr=r;
else xr=l;
break;
}
if(!ask(x,log+y)){
r=y+log;
l=y+(log/2);
break;
}
log*=2;
}
while(r-l>1){
int mid=(l+r)/2;
if(ask(x,mid))
l=mid;
else r=mid;
}
if(ask(x,r))
yn=r;
else yn=l;
int p=1;
int m=xr-xl+1;
int x=(xr+xl)/2;
int y=yn-(m/2);
int ax=0,ay=0;
int ind1=0,ind2=0;
if(y+2*m<=n && ask(x,y+2*m)){
ind1=1;
p++;
}
if(y+4*m<=n && ask(x,y+4*m)){
p++;
}
if(y-2*m>=1 && ask(x,y-2*m)){
p++;
}
if(y-4*m>=1 && ask(x,y-4*m)){
p++;
}
if(p!=3){
x-=m;
y-=m;
ind1=1;
}
if(y+4*m<=n && ask(x,y+4*m)){
ind2=1;
}
if(ind2==1){
ay=y+2*m;
}
else{
if(ind1==1)
ay=y;
else{
ay=y-2*m;
}
}
ind1=0,ind2=0;
if(x+2*m<=n && ask(x+2*m,y))
ind1=1;
if(x+4*m<=n && ask(x+4*m,y))
ind2=1;
if(ind2==1){
ax=x+2*m;
}
else{
if(ind1==1)
ax=x;
else{
ax=x-2*m;
}
}
cout<<"solution"<<' '<<ax<<' '<<ay<<endl;
return 0;
}
Compilation message (stderr)
aliens.cpp: In function 'bool ask(long long int, long long int)':
aliens.cpp:11:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(s=="true")
^~
aliens.cpp:13:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
return false;
^~~~~~
aliens.cpp: At global scope:
aliens.cpp:16:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |