题意:有一个n边形的城堡,在外围造一个总长度尽量小的围墙,使得任何一部分离城堡的距离不小于L,输出围墙长度。
题解:先把n个点求凸包,然后围墙一定是凸包的每条边向外扩增距离L,然后每个拐弯的部分是半径为L的圆弧这样总长度才尽量小。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1);

int dcmp(double x) {
    if (fabs(x) < eps)
        return 0;
    return x > 0 ? 1 : -1;
}
struct Point {
    double x, y;
    Point (double a = 0, double b = 0): x(a), y(b) {}
};
typedef Point Vector;
typedef vector<Point> Polygon;

Vector operator + (const Vector& a, const Vector& b) { return Vector(a.x + b.x, a.y + b.y); }
Vector operator - (const Vector& a, const Vector& b) { return Vector(a.x - b.x, a.y - b.y); }
Vector operator * (const Vector& a, double& b) { return Vector(a.x * b, a.y * b); }
Vector operator / (const Vector& a, double& b) { return Vector(a.x / b, a.y / b); }
bool operator == (const Vector& a, const Vector& b) { return !dcmp(a.x - b.x) && !dcmp(a.y - b.y); }
bool operator < (const Vector& a, const Vector& b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }
double Dot(const Vector& a, const Vector& b) { return a.x * b.x + a.y * b.y; }
double Length(const Vector& a) { return sqrt(Dot(a, a)); }
double Cross(const Vector& a, const Vector& b) { return a.x * b.y - a.y * b.x; }
double Angle(const Vector& a, const Vector& b) { return acos(Dot(a, b) / Length(a) / Length(b)); }

int ConvexHull(Point* P, int cnt, Point* res) {
    sort(P, P + cnt);
    cnt = unique(P, P + cnt) - P;
    int m = 0;
    for (int i = 0; i < cnt; i++) {
        while (m > 1 && Cross(res[m - 1] - res[m - 2], P[i] - res[m - 2]) <= 0)
            m--;
        res[m++] = P[i];
    }
    int k = m;
    for (int i = cnt - 2; i >= 0; i--) {
        while (m > k && Cross(res[m - 1] - res[m - 2], P[i] - res[m - 2]) <= 0)
            m--;
        res[m++] = P[i];
    }
    if (cnt > 1)
        m--;
    return m;
}

const int N = 1005;
int n;
double L;
Point R[N], P[N];

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        scanf("%d%lf", &n, &L);
        for (int i = 0; i < n; i++)
            scanf("%lf%lf", &R[i].x, &R[i].y);
        int cnt = ConvexHull(R, n, P);
        P[cnt] = P[0];
        double res = 0;
        for (int i = 0; i < cnt; i++)
            res += Length(P[i] - P[i + 1]); 
        printf("%.0lf\n", res + 2 * PI * L);
        if (t)
            printf("\n");
    }
    return 0;
}