# poj 1113 Wall

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int Max = 1005;
const double PI = 3.141592653;

struct Point{
double x, y;
}p[Max];
int n, res[Max], top;

bool cmp(struct Point a, struct Point b){
if(a.y == b.y) return a.x < b.x;
return a.y < b.y;
}

double mult(Point sp, Point ep, Point op){
return (sp.x-op.x)*(ep.y-op.y) - (ep.x-op.x)*(sp.y-op.y);
}

double mydis(int i, int j){
double a = p[i].x - p[j].x;
double b = p[i].y - p[j].y;
return sqrt(a*a + b*b);
}

void Graham(){
int i, len;
top = 1;
sort(p, p+n, cmp);//p[0]是最左下的点，p[n-1]是最右上的点
for(i = 0; i < 3; i ++) res[i] = i;
for(i = 2; i < n; i ++){
while(top && mult(p[i], p[res[top]], p[res[top-1]]) >= 0) top --;
res[++ top] = i;
}//凸包画了下面一半
len = top;
res[++ top] = n-2;
for(i = n - 3; i >= 0; i --){
while(top != len && mult(p[i], p[res[top]], p[res[top-1]]) >= 0) top --;
res[++ top] = i;
}//剩下一半
}

int main(){
int i;
double r, ans;
scanf("%d%lf", &n, &r);
for(i = 0; i < n; i ++)
scanf("%lf%lf", &p[i].x, &p[i].y);
Graham();
ans = 2 * PI * r;
for(i = 0; i < top-1; i ++)
ans += mydis(res[i], res[i+1]);
ans += mydis(res[0], res[top-1]);
printf("%.lf\n", ans);
return 0;
}

#### POJ1113Wall（计算几何基础）

2013-05-25 21:23:14

#### POJ 1113 Wall 凸包(模板题)

2017-04-18 15:50:32

#### [poj 1113]Wall[凸包]

2013-08-27 20:33:28

#### POJ 1113 Wall（凸包）

2015-08-27 16:54:10

#### POJ 1113 Wall

2013-11-12 20:22:07

#### poj 1113 Wall （计算几何）

2016-08-15 16:11:20

#### poj 1113 Wall

2014-07-12 20:05:27

#### POJ 1113 Wall (凸包)

2014-07-12 18:51:43

#### POJ 1113 Wall 凸包

2014-07-18 15:58:32

#### poj 1113 Wall (凸包)

2014-08-04 15:23:36