poj 1113wall (凸包)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define LL long long
#define M 1002
#define DEBUG puts("It's here!")
#define INF 1<<29
#define PI acos(-1.0)
#define CLS(x,v) memset(x,v,sizeof(x))
#define FOR(i,w,n) for(int i=(w);i<=(n);++i)
struct point
{
int x,y;
void input()
{
scanf("%d%d",&x,&y);
}
point() {}
point(int vx,int vy)
{
x=vx;
y=vy;
}
point operator -(const point &b)
{
return point(x-b.x,y-b.y);
}
} p[M];
int cross(point a,point b )
{
return a.x*b.y-a.y*b.x;
}
double dist(point a)
{
return sqrt(1.0*a.x*a.x+a.y*a.y);
}
int cmp(point a,point b)
{
int ret=cross(a-p[0],b-p[0]);
if(ret==0)return dist(a-p[0])>dist(b-p[0]);
else return ret>0;
}
int st[M],cnt;
int n,L;
void graham()
{
int k=0,i;
for(i=1; i<n; i++)
if(p[i].x<p[k].x||(p[i].x==p[k].x&&p[i].y<p[k].y))
{
k=i;
}
swap(p[0],p[k]);
sort(p+1,p+n,cmp);
cnt=0;i=3;
st[cnt]=0;
st[++cnt]=1;
st[++cnt]=2;
while(i<n)
{
while(cnt>1&&cross(p[st[cnt]]-p[st[cnt-1]],p[i]-p[st[cnt]])<0)
cnt--;
st[++cnt]=i++;
}
st[++cnt]=0;
double ans=0.0;
for(i=1; i<=cnt; i++)
{ // printf("-->%d %d\n",p[st[i]].x,p[st[i]].y);
ans+=dist(p[st[i]]-p[st[i-1]]);
}
printf("%.0lf\n",ans+2*PI*L);
}
int main()
{
while(~scanf("%d%d",&n,&L))
{
for(int i=0; i<n; i++)
{
p[i].input();
}
graham();
}
return 0;
}