# [BZOJ1670][Usaco2006 Oct]Building the Moat护城河的挖掘

## 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘

Time Limit: 3 Sec  Memory Limit: 64 MB Submit: 628  Solved: 466 [Submit][Status][Discuss]

## Input

* 第1行: 一个整数，N * 第2..N+1行: 每行包含2个用空格隔开的整数，x[i]和y[i]，即第i股泉水的位 置坐标

## Output

* 第1行: 输出一个数字，表示满足条件的护城河的最短长度。保留两位小数

20
2 10
3 7
22 15
12 11
20 3
28 9
1 12
9 3
14 14
25 6
8 1
25 1
28 4
24 12
4 15
13 5
26 5
21 11
24 4
1 8

## Sample Output

70.87

#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char buf[10000000], *ptr = buf - 1;
int f = 1, n = 0;
char ch = *++ptr;
while(ch < '0' || ch > '9'){
if(ch == '-') f = -1;
ch = *++ptr;
}
while(ch <= '9' && ch >= '0'){
n = (n << 1) + (n << 3) + ch - '0';
ch = *++ptr;
}
return f * n;
}
typedef long long ll;
const int maxn = 5000 + 10;
struct Point{
ll x, y;
Point(ll _x = 0, ll _y = 0): x(_x), y(_y){}
Point operator - (const Point &a) const {
return Point(x - a.x, y - a.y);
}
ll operator % (const Point &a){
return x * a.y - a.x * y;
}
}p[maxn];
class cmp{
public:
bool operator () (const Point &a, const Point &b){
return (a - p[1]) % (b - p[1]) > 0;
}
};
inline ll sqr(const ll &x){
return x * x;
}
inline double dis(const Point &a, const Point &b){
return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
int n;
Point sta[maxn];
int top = 0;
void Graham(){
int t = 1;
for(int i = 2; i <= n; i++)
if(p[i].x < p[t].x || p[i].x == p[t].x && p[i].y < p[t].y) t = i;
swap(p[t], p[1]);
sort(p + 2, p + n + 1, cmp());
sta[++top] = p[1];
for(int i = 2; i <= n; i++){
while(top > 1 && (p[i] - sta[top - 1]) % (sta[top] - sta[top - 1]) > 0) top--;
sta[++top] = p[i];
}
sta[top + 1] = p[1];
}
int main(){
fread(buf, sizeof(char), sizeof(buf), stdin);
for(int i = 1; i <= n; i++){
}