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,x,y;
ll bn,bs,be,bw;
int cnt;
bool examine(ll x, ll y) {
if (x<1 || y<1 || x>n || y>n) return false;
cout<<"examine "<<x<<" "<<y<<flush;
string s;
cin>>s;
if (s=="true") return true;
else return false;
}
int main() {
cin>>n>>x>>y;
//east
ll k=1;
while (examine(x+k,y) && cnt<10) k*=2,cnt++;
ll l=x, r=min(n,x+k);
/*
while (r>=l) {
ll mid=(l+r)/2;
if (examine(mid,y)) l=mid+1;
else r=mid-1;
}
be=r; */
/*
//north
k=1;
while (examine(x,y+k)) k*=2;
l=y; r=min(n,y+k);
while (r>=l) {
ll mid=(l+r)/2;
if (examine(x,mid)) l=mid+1;
else r=mid-1;
}
bn=r;
//west
k=1;
while (examine(x-k,y)) k*=2;
l=max(1ll,x-k); r=x;
while (r>=l) {
int mid=(l+r)/2;
if (examine(mid,y)) r=mid-1;
else l=mid+1;
}
bw=l;
//south
k=1;
while (examine(x,y-k)) k*=2;
l=y; r=max(1ll,y-k);
while (r>=l) {
int mid=(l+r)/2;
if (examine(x,mid)) r=mid-1;
else l=mid+1;
}
bs=l;
*/
ll cx=(be+bw)/2, cy=(bn+bs)/2, sz=(be-bw+1)*2;
ll ansx, ansy;
/*
if (examine(cx+sz,cy)) { //have right
if (examine(cx+2*sz,cy)) { //have 2 right
ansx=cx+sz;
if (examine(ansx,cy+2*sz)) ansy=cy+sz;
else if (examine(ansx,cy-2*sz)) ansy=cy-sz;
else ansy=cy;
} else if (examine(cx-sz,cy)) { // have left and right
ansx=cx;
if (examine(ansx,cy+2*sz)) ansy=cy+sz;
else if (examine(ansx,cy-2*sz)) ansy=cy-sz;
else ansy=cy;
} else {
ansx=cx+sz/2;
if (examine(ansx,cy+3*(sz/2))) ansy=cy+sz/2;
else ansy=cy-sz/2;
}
} else { //have left
if (examine(cx-2*sz,cy)) { //have 2 left
ansx=cx-sz;
if (examine(ansx,cy+2*sz)) ansy=cy+sz;
else if (examine(ansx,cy-2*sz)) ansy=cy-sz;
else ansy=cy;
} else {
ansx=cx-sz/2;
if (examine(ansx,cy+3*(sz/2))) ansy=cy+sz/2;
else ansy=cy-sz/2;
}
}
*/
cout<<"solution "<<ansx<<" "<<ansy<<flush;
}
Compilation message (stderr)
aliens.cpp: In function 'int main()':
aliens.cpp:24:8: warning: unused variable 'l' [-Wunused-variable]
24 | ll l=x, r=min(n,x+k);
| ^
aliens.cpp:24:13: warning: unused variable 'r' [-Wunused-variable]
24 | ll l=x, r=min(n,x+k);
| ^
aliens.cpp:66:8: warning: unused variable 'cx' [-Wunused-variable]
66 | ll cx=(be+bw)/2, cy=(bn+bs)/2, sz=(be-bw+1)*2;
| ^~
aliens.cpp:66:22: warning: unused variable 'cy' [-Wunused-variable]
66 | ll cx=(be+bw)/2, cy=(bn+bs)/2, sz=(be-bw+1)*2;
| ^~
aliens.cpp:66:36: warning: unused variable 'sz' [-Wunused-variable]
66 | ll cx=(be+bw)/2, cy=(bn+bs)/2, sz=(be-bw+1)*2;
| ^~
aliens.cpp:107:24: warning: 'ansx' is used uninitialized in this function [-Wuninitialized]
107 | cout<<"solution "<<ansx<<" "<<ansy<<flush;
| ^~~~
aliens.cpp:107:35: warning: 'ansy' is used uninitialized in this function [-Wuninitialized]
107 | cout<<"solution "<<ansx<<" "<<ansy<<flush;
| ^~~~
# | 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... |