/******************************************
* AUTHOR: CHIRAG AGARWAL *
* INSTITUITION: BITS PILANI, PILANI *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
const int MAX=2e5+5;
const long double eps=1e-20;
struct Point
{
LL x,y;
int ind;
Point(LL a,LL b)
{
x=a;
y=b;
}
Point(){}
Point operator +(const Point &a)
{
return Point(a.x+x,a.y+y);
}
Point operator -(const Point &a)
{
return Point(x-a.x,y-a.y);
}
};
LL cross(Point a,Point b)
{
return ((a.x*b.y)-(b.x*a.y));
}
LL dot(Point a,Point b)
{
return ((a.x*b.x)+(a.y*b.y));
}
double mag(Point a)
{
return sqrt(dot(a,a));
}
int ind;
int n;
Point arr[MAX];
Point vec[MAX];
LL ans[MAX];
vector<Point> quad[5];
Point dir[5];
int ref[5];
bool cmp(Point a,Point b)
{
return ((dot(a,dir[ind])/mag(a))>(dot(b,dir[ind])/mag(b)));
}
Point lo;
bool scmp(Point a,Point b)
{
LL val=cross(a-lo,b-lo);
if(val==0)
{
return (mag(a-lo)<mag(b-lo));
}
else
{
return val>0;
}
}
vector<Point> hull;
void get_hull()
{
int lm=1;
for(int i=2;i<=n;i++)
{
if(arr[i].x<arr[lm].x||(arr[i].x==arr[lm].x&&arr[i].y<arr[lm].y))
{
lm=i;
}
}
lo=arr[lm];
swap(arr[1],arr[lm]);
sort(arr+2,arr+n+1,scmp);
hull.push_back(arr[1]);
hull.push_back(arr[2]);
int hull_sz=2;
for(int i=3;i<=n;i++)
{
while(hull.size()>1&&cross(arr[i]-hull[hull.size()-2],hull[hull.size()-1]-hull[hull.size()-2])>0)
{
hull.pop_back();
hull_sz--;
}
hull.push_back(arr[i]);
hull_sz++;
}
int tm=0;
int lem=0;
int rm=0;
int bm=0;
for(int i=1;i<hull.size();i++)
{
if(hull[i].y>hull[tm].y)
{
tm=i;
}
if(hull[i].y<hull[bm].y)
{
bm=i;
}
if(hull[i].x<hull[lem].x)
{
lem=i;
}
if(hull[i].x>hull[rm].x)
{
rm=i;
}
}
ref[1]=rm;
ref[2]=tm;
ref[3]=lem;
ref[4]=bm;
}
int main()
{
int t=1;
dir[1]=Point(1,0);
dir[2]=Point(0,1);
dir[3]=Point(-1,0);
dir[4]=Point(0,-1);
//scanf("%d",&t);
while(t--)
{
for(int i=1;i<=4;i++)
{
quad[i].clear();
}
hull.clear();
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
long double a,b;
scanf("%Lf %Lf",&a,&b);
vec[i].x=a*1000;
vec[i].y=b*1000;
// printf("%lld %lld\n",vec[i].x,vec[i].y);
vec[i].ind=i;
if(vec[i].x>0&&vec[i].y>=0)
{
quad[1].push_back(vec[i]);
}
else if(vec[i].x<0&&vec[i].y<=0)
{
quad[3].push_back(vec[i]);
}
else if(vec[i].x<=0&&vec[i].y>0)
{
quad[2].push_back(vec[i]);
}
else
{
quad[4].push_back(vec[i]);
}
}
for(int i=1;i<=4;i++)
{
ind=i;
sort(quad[i].begin(),quad[i].end(),cmp);
}
for(int i=1;i<=n;i++)
{
arr[i]=vec[i];
}
if(n==1)
{
for(int i=1;i<=n;i++)
{
ans[vec[i].ind]=dot(vec[i],arr[1]);
}
}
else
{
get_hull();
for(int i=1;i<=4;i++)
{
int ptr1=0;
int ptr2=ref[i];
while(ptr1<quad[i].size())
{
while(true)
{
if(dot(quad[i][ptr1],hull[(ptr2+1)%hull.size()])>dot(quad[i][ptr1],hull[ptr2]))
{
ptr2=(ptr2+1)%hull.size();
}
else
{
break;
}
}
ans[quad[i][ptr1].ind]=dot(quad[i][ptr1],hull[ptr2]);
ptr1++;
}
}
}
for(int i=1;i<=n;i++)
{
LL tmp=ans[i];
// printf("%lld\n",ans[i]);
for(int j=0;j<3;j++)
{
int dig=tmp%10;
tmp/=10;
if(dig>=5)
{
tmp++;
}
}
int dig[3];
for(int j=0;j<3;j++)
{
dig[j]=tmp%10;
tmp/=10;
}
int cur=dig[2]*100+dig[1]*10+dig[0];
printf("%lld.%.3d\n",tmp,cur);
}
}
return 0;
}
L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QoJCX0KCQlmb3IoaW50IGk9MTtpPD1uO2krKykKCQl7CgkJCUxMIHRtcD1hbnNbaV07CgkJLy8JcHJpbnRmKCIlbGxkXG4iLGFuc1tpXSk7CgkJCWZvcihpbnQgaj0wO2o8MztqKyspCgkJCXsKCQkJCWludCBkaWc9dG1wJTEwOwoJCQkJdG1wLz0xMDsKCQkJCWlmKGRpZz49NSkKCQkJCXsKCQkJCQl0bXArKzsKCQkJCX0KCQkJfQoJCQlpbnQgZGlnWzNdOwoJCQlmb3IoaW50IGo9MDtqPDM7aisrKQoJCQl7CgkJCQlkaWdbal09dG1wJTEwOwoJCQkJdG1wLz0xMDsKCQkJfQoJCQlpbnQgY3VyPWRpZ1syXSoxMDArZGlnWzFdKjEwK2RpZ1swXTsKCQkJcHJpbnRmKCIlbGxkLiUuM2RcbiIsdG1wLGN1cik7CgkJfQoJfQkJCiAKCXJldHVybiAwOwp9IA==
prog.cpp: In function ‘void get_hull()’:
prog.cpp:138:2: error: reference to ‘ref’ is ambiguous
ref[1]=rm;
^~~
prog.cpp:60:5: note: candidates are: int ref [5]
int ref[5];
^~~
In file included from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:71:0,
from prog.cpp:5:
/usr/include/c++/6/functional:491:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(std::reference_wrapper<_Tp>)
ref(reference_wrapper<_Tp> __t) noexcept
^~~
/usr/include/c++/6/functional:483:10: note: template<class _Tp> void std::ref(const _Tp&&)
void ref(const _Tp&&) = delete;
^~~
/usr/include/c++/6/functional:473:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)
ref(_Tp& __t) noexcept
^~~
prog.cpp:139:2: error: reference to ‘ref’ is ambiguous
ref[2]=tm;
^~~
prog.cpp:60:5: note: candidates are: int ref [5]
int ref[5];
^~~
In file included from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:71:0,
from prog.cpp:5:
/usr/include/c++/6/functional:491:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(std::reference_wrapper<_Tp>)
ref(reference_wrapper<_Tp> __t) noexcept
^~~
/usr/include/c++/6/functional:483:10: note: template<class _Tp> void std::ref(const _Tp&&)
void ref(const _Tp&&) = delete;
^~~
/usr/include/c++/6/functional:473:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)
ref(_Tp& __t) noexcept
^~~
prog.cpp:140:2: error: reference to ‘ref’ is ambiguous
ref[3]=lem;
^~~
prog.cpp:60:5: note: candidates are: int ref [5]
int ref[5];
^~~
In file included from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:71:0,
from prog.cpp:5:
/usr/include/c++/6/functional:491:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(std::reference_wrapper<_Tp>)
ref(reference_wrapper<_Tp> __t) noexcept
^~~
/usr/include/c++/6/functional:483:10: note: template<class _Tp> void std::ref(const _Tp&&)
void ref(const _Tp&&) = delete;
^~~
/usr/include/c++/6/functional:473:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)
ref(_Tp& __t) noexcept
^~~
prog.cpp:141:2: error: reference to ‘ref’ is ambiguous
ref[4]=bm;
^~~
prog.cpp:60:5: note: candidates are: int ref [5]
int ref[5];
^~~
In file included from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:71:0,
from prog.cpp:5:
/usr/include/c++/6/functional:491:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(std::reference_wrapper<_Tp>)
ref(reference_wrapper<_Tp> __t) noexcept
^~~
/usr/include/c++/6/functional:483:10: note: template<class _Tp> void std::ref(const _Tp&&)
void ref(const _Tp&&) = delete;
^~~
/usr/include/c++/6/functional:473:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)
ref(_Tp& __t) noexcept
^~~
prog.cpp: In function ‘int main()’:
prog.cpp:211:14: error: reference to ‘ref’ is ambiguous
int ptr2=ref[i];
^~~
prog.cpp:60:5: note: candidates are: int ref [5]
int ref[5];
^~~
In file included from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:71:0,
from prog.cpp:5:
/usr/include/c++/6/functional:491:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(std::reference_wrapper<_Tp>)
ref(reference_wrapper<_Tp> __t) noexcept
^~~
/usr/include/c++/6/functional:483:10: note: template<class _Tp> void std::ref(const _Tp&&)
void ref(const _Tp&&) = delete;
^~~
/usr/include/c++/6/functional:473:5: note: template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)
ref(_Tp& __t) noexcept
^~~