题目链接:
题意:
给定n个点,用n个点组成的多边形中(可以是凹多边形,但n个点一定要全在多边形上)
在所有能由n个点构成的多边形中
求最小面积的多边形的周长 - 最小周长。
思路:
首先我们选择一个定点,则接下来的数进行一个排列,有(n-1)!个排列。
这个序列相邻两个数之间有一条线段。
判断多边形合法:任意两条线段不相交即可。n^2
剩下就是简单的更新答案了。
所以复杂度是 ( n-1 ) ! * n*n
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
const int MAX_N = 2507;
struct point {
double x, y;
point(double _x = 0, double _y = 0) {
x = _x, y = _y;
}
bool operator < (const point &rhs) const {
if (x != rhs.x) return x < rhs.x;
return y < rhs.y;
}
};
int n;
int top;
point st[100], p[100];
typedef point Point;
double cross(point p0, point p1, point p2) {
return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0