#include <iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#define PI 3.14159265358979323846
using namespace std;
const int MAX=1050;
struct P
{
int x,y;
P()
{
}
P(int x1,int y1)
{
x=x1;
y=y1;
}
int det(P p)
{
return x*p.y-y*p.x;
}
int dot(P p)
{ return x*p.x + y*p.y; }
P operator - (P p)
{
return P(x-p.x,y-p.y);
}
}p[MAX];
bool cmp(const P& f,const P &s)
{
if(s.x!=f.x)
return f.x<s.x;
return f.y<s.y;
}
int n,l;
vector<P> convex()
{
int k=0;
vector<P> q(2*n);
for(int i=0;i<n;i++)
{
while(k>1&&(q[k-1]-q[k-2]).det(p[i]-q[k-1])<=0)
k--;
q[k++]=p[i];
}
for(int i=n-2,t=k;i>=0;i--)
{
while(k>t&&(q[k-1]-q[k-2]).det(p[i]-q[k-1])<=0)
k--;
q[k++]=p[i];
}
q.resize(k-1);
return q;
}
double dis(P p, P q)
{
return sqrt((double)(p - q).dot(p - q));
}
int main()
{
scanf("%d%d",&n,&l);
for(int i=0;i<n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
sort(p,p+n,cmp);
vector<P> res=convex();
double ans=0;
int num=res.size();
for(int i=0;i<num;i++)
{
ans+=dis(res[i],res[(i+1)%num]);
}
ans+=(2*PI*l);
printf("%.0lf\n",ans);
return 0;
}
poj1113Wall
最新推荐文章于 2020-10-28 13:39:49 发布