The test instructions of this is that the distance between all points on the circle and the original point is greater than or equal to L. To find the shortest perimeter.
Translate it, geometric mess? found that the arc was just a circle.
Convexhull. This I copy of the version also do not know what algorithm but it seems to be reliable. An algorithm for the study of convex hull.
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace Std;
struct POINT
{
int x, y;
Point (int x=0,int y=0): X (x), Y (y) {}
};
typedef point Vector;
Point ch[1010],p[1010];
Const Double Pi=atan (1.0);
int n;
int cross (vector a,vector B)
{
return a.x*b.y-a.y*b.x;
}
Vector operator + (vector a,vector b)
{
return vector (A.X+B.X,A.Y+B.Y);
}
Vector operator-(vector a,vector B)
{
return vector (A.X-B.X,A.Y-B.Y);
}
Vector operator * (vector a,double p)
{
return vector (a.x*p,a.y*p);
}
Vector operator/(vector a,double p)
{
return vector (a.x/p,a.y/p);
}
BOOL Operator < (point A,point B)
{
return a.x<b.x| | (a.x==b.x && a.y<b.y);
}
Double Dis (point a,point B)
{
return sqrt (1.0* (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y));
}
int Convexhull ()
{
Sort (p,p+n);
int m=0,k;
for (int i=0;i<n;i++)
{
while (M>1 && Cross (ch[m-1]-ch[m-2],p[i]-ch[m-2]) <=0)
m--;
Ch[m++]=p[i];
}
K=m;
for (int i=n-2;i>=0;i--)
{
while (M>k && Cross (ch[m-1]-ch[m-2],p[i]-ch[m-2]) <=0)
m--;
Ch[m++]=p[i];
}
if (n>1) m--;
return m;
}
int main ()
{
int l;
while (scanf ("%d%d", &n,&l) ==2)
{
for (int i=0;i<n;i++)
scanf ("%d%d", &p[i].x,&p[i].y);
int M=convexhull ();
Double ans=0;
for (int i=1;i<m;i++)
Ans=ans+dis (Ch[i-1],ch[i]);
Ans=ans+dis (Ch[0],ch[m-1]);
Ans=ans+2.0*pi*l;
printf ("%d\n", int (ans+0.5));
}
return 0;
}
POJ 1113 Wall