# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1140157 | bestbest | Aliens (IOI07_aliens) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define en '\n'
#define sp ' '
typedef long long ll;
#define Linux ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pii pair<int,int>
#include "grader.cpp"
int n,mxr,mxl,myu,myd,x,y,ix,iy;
int bp(int l,int r,bool chk){//x==1,y==0
while(l<r){
int mid=(l+r)/2;
if(examine(x+ (chk?mid:0) ,y+ (chk?0:mid) ))l=mid+1;
else r=mid;
}
return l-1;
}
int bn(int l,int r,bool chk){//x==1,y==0
while(l<r){
int mid=(l+r)/2;
if(examine(x- (chk?mid:0) ,y- (chk?0:mid) ))l=mid+1;
else r=mid;
}
return l-1;
}
int main(){
int a=1,b=1;
int mx,my;
cin >> n >> x >> y;
cout << endl;
while (examine(x+a,y))a*=2;
while (examine(x,y+b))b*=2;
a/=2,b/=2;
mxr=bp(a,a*2,1);
myu+=bp(b,b*2,0);
a=1,b=1;
while (examine(x-a,y))a*=2;
while (examine(x,y-b))b*=2;
a/=2,b/=2;
mxl=-bn(a,a*2,1);
myd=-bn(b,b*2,0);
mx=x+(mxr+mxl);
my=y+(myu+myd);
int si=mxr-mxl;
int ax,ay;
if(examine(mx+si*2,my+si*2) && examine(mx-si*2,my-si*2)){//mid
ax=mx;
ay=my;
}
else if(examine(mx+si*4,my-si*4)){//leftup
ax=mx+si*2;
ay=mx-si*2;
}
else if(examine(mx+si*4,my+si*4)){//leftdown
ax=mx+si*2;
ay=mx+si*2;
}
else if(examine(mx-si*4,my-si*4)){//rightup
ax=mx-si*2;
ay=mx-si*2;
}
else if(examine(mx-si*4,my+si*4)){//rightdown
ax=mx-si*2;
ay=mx+si*2;
}
else if(examine(mx-si,my+si) && examine(mx+si*3,my-si*3)){//lilleftup
ax=mx+si;
ay=mx-si;
}
else if(examine(mx-si,my-si) && examine(mx+si*3,my=si*3)){//lilleftdown
ax=mx+si;
ay=mx+si;
}
else if(examine(mx+si,my+si) && examine(mx-si*3,my-si*3)){//lilrightup
ax=mx-si;
ay=mx-si;
}
else if(examine(mx+si,my-si) && examine(mx-si*3,my+si*3)){//lilrightdown
ax=mx-si;
ay=mx+si;
}
//cout << ax << sp << ay;
solution(ax,ay);
return 0;
}