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;
bool examine(int a, int b)
{
printf("examine %d %d\n",a,b);
fflush(stdout);
int ret;
scanf(" %d",&ret);
return ret;
}
void solution(int a, int b)
{
printf("solution %d %d\n",a,b);
fflush(stdout);
}
int main()
{
long long n, x, y, l, r, L, R, T, B, sz;
scanf(" %lld %lld %lld",&n,&x,&y);
//right
l = x, r = n;
while(l != r)
{
long long mid = (l+r+1)>>1ll;
if(!examine(mid, y)) r = mid-1;
else if(!examine((l+mid)>>1ll, y)) r = mid-1;
else if(!examine((l+((l+mid)>>1ll))>>1ll, y)) r = mid-1;
else l = mid;
}
R = l;
//left
l = 1, r = x;
while(l != r)
{
long long mid = (l+r)>>1ll;
if(!examine(mid, y)) l = mid+1;
else if(!examine((mid+r)>>1ll, y)) l = mid+1;
else if(!examine((((mid+r)>>1ll)+r)>>1ll, y)) l = mid+1;
else r = mid;
}
L = l;
//top
l = y, r = n;
while(l != r)
{
long long mid = (l+r+1)>>1ll;
if(!examine(x, mid)) r = mid-1;
else if(!examine(x, (l+mid)>>1ll)) r = mid-1;
else if(!examine(x, (l+((l+mid)>>1ll))>>1ll)) r = mid-1;
else l = mid;
}
T = l;
sz = R-L+1;
B = T-sz+1;
long long mx = (L+R)>>1ll, my = (B+T)>>1ll;
int tl = 0, tr = 0, bl = 0, br = 0;
for(int i=1 ; i<=4 ; i++)
{
if(mx - i*sz >= 1 && my + i*sz <= n && examine(mx-i*sz, my+i*sz)) tl++;
if(mx + i*sz <= n && my + i*sz <= n && examine(mx+i*sz, my+i*sz)) tr++;
if(mx - i*sz >= 1 && my - i*sz >= 1 && examine(mx-i*sz, my-i*sz)) bl++;
if(mx + i*sz <= n && my - i*sz >= 1 && examine(mx+i*sz, my-i*sz)) br++;
}
if(tl == 0)
{
if(tr == 4) solution(mx+2*sz, my+2*sz);
else if(bl == 4) solution(mx-2*sz, my-2*sz);
else if(br == 4) solution(mx+2*sz, my-2*sz);
else if(tr == 2) solution(mx+sz, my);
else solution(mx, my-sz);
}
else if(tl == 1)
{
if(tr == 3) solution(mx+sz, my+sz);
else if(bl == 3) solution(mx-sz, my-sz);
else solution(mx+sz, my-sz);
}
else if(tl == 2)
{
if(bl + br == 0) solution(mx, my+sz);
else if(bl + br == 2) solution(mx-sz, my);
else solution(mx, my);
}
else if(tl == 3) solution(mx-sz, my+sz);
else solution(mx-2*sz, my+2*sz);
return 0;
}
Compilation message (stderr)
aliens.cpp: In function 'bool examine(int, int)':
aliens.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d",&ret);
~~~~~^~~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %lld %lld %lld",&n,&x,&y);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |