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,x,y;
int m,xa,ya;
bool examn(int xe,int ye){
if(xe<1||xe>n||ye<1||ye>n)
return false;
cout<<"examin "<<xe<<' '<<ye<<'\n';
fflush(stdout);
string in;
cin>>in;
if(in=="true")
return true;
return false;
}
bool examnx(int xb,int yb,int xe){
if(xe<1)
return false;
if(xb>xe){
int l=xb,r=xe;
while(examn(r,yb)&&l>r){
r=l-(r-l)/2;
}
if(r>=l)
return true;
return false;
}else{
int l=xb,r=xe;
while(examn(r,yb)&&r>l){
r=(r-l)/2+l;
}
if(r<=l)
return true;
return false;
}
}
bool examny(int xb,int yb,int ye){
if(ye<1)
return false;
if(yb>ye){
int l=yb,r=ye;
while(examn(xb,r)&&l>r){
r=l-(r-l)/2;
}
if(r>=l)
return true;
return false;
}else{
int l=yb,r=ye;
while(examn(xb,r)&&r>l){
r=(r-l)/2+l;
}
if(r<=l)
return true;
return false;
}
}
int32_t main()
{
cin>>n>>y>>x;
int l=0,r=3e9;
int ux,lx,ly,ry;
while(l<=r){
int mid=(r-l)/2+l;
if(examnx(x,y,x+mid)){
ux=x+mid;
l=mid+1;
}else{
r=mid-1;
}
}
l=0,r=3e9;
while(l<=r){
int mid=(r-l)/2+l;
if(examnx(x,y,x-mid)){
lx=x-mid;
l=mid+1;
}else{
r=mid-1;
}
}
l=0,r=3e9;
while(l<=r){
int mid=(r-l)/2+l;
if(examny(x,y,y+mid)){
ry=y+mid;
l=mid+1;
}else{
r=mid-1;
}
}
l=0,r=3e9;
while(l<=r){
int mid=(r-l)/2+l;
if(examny(x,y,y-mid)){
ly=y-mid;
l=mid+1;
}else{
r=mid-1;
}
}
int h=0,w=0;
l=0,r=3e9;
int up=0;
while(l<=r){
int mid=(r-l)/2+l;
if(examn(x,ry+2*(ry-ly+1)*mid)){
l=mid+1;
up=ry+2*(ry-ly+1)*mid;
}else{
r=mid-1;
}
}
l=0,r=3e9;
int dn=0;
while(l<=r){
int mid=(r-l)/2+l;
if(examn(x,ly-2*(ry-ly+1)*mid)){
l=mid+1;
dn=ly-2*(ry-ly+1)*mid;
}else{
r=mid-1;
}
}
l=0,r=3e9;
int rt=0;
while(l<=r){
int mid=(r-l)/2+l;
if(examn(ux+2*(ry-ly+1)*mid,y)){
l=mid+1;
rt=ux+2*(ry-ly+1)*mid;
}else{
r=mid-1;
}
}
l=0,r=3e9;
int lf=0;
while(l<=r){
int mid=(r-l)/2+l;
if(examn(lx-2*(ry-ly+1)*mid,y)){
l=mid+1;
lf=lx-2*(ry-ly+1)*mid;
}else{
r=mid-1;
}
}
cout<<"solution "<<(rt-lf)/2+lf<<' '<<(up-dn)/2+dn<<'\n';
///fflush(stdout);
return 0;
}
/****
1
8 4
3 1
4 3
1 8
8 7
1
100 9
1 100
2 1
3 2
4 3
5 4
100 99
99 98
98 97
97 96
19 3 6
3 12 9
2000000000 1000000000 1000000000
3 1000000000 1000000000
*/
Compilation message (stderr)
aliens.cpp: In function 'int32_t main()':
aliens.cpp:111:9: warning: unused variable 'h' [-Wunused-variable]
111 | int h=0,w=0;
| ^
aliens.cpp:111:13: warning: unused variable 'w' [-Wunused-variable]
111 | int h=0,w=0;
| ^
aliens.cpp:127:17: warning: 'ly' may be used uninitialized in this function [-Wmaybe-uninitialized]
127 | if(examn(x,ly-2*(ry-ly+1)*mid)){
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:116:17: warning: 'ry' may be used uninitialized in this function [-Wmaybe-uninitialized]
116 | if(examn(x,ry+2*(ry-ly+1)*mid)){
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:149:17: warning: 'lx' may be used uninitialized in this function [-Wmaybe-uninitialized]
149 | if(examn(lx-2*(ry-ly+1)*mid,y)){
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:138:17: warning: 'ux' may be used uninitialized in this function [-Wmaybe-uninitialized]
138 | if(examn(ux+2*(ry-ly+1)*mid,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... |