题意:求凸包,求面积,然后给面积除以50,向下取整。
用的Andrew算法,即跑两次,先求出下凸包,然后再求出上凸包。
求面积时候应该用凸包数组求,结果写成了原来的点的数组,调了20多分钟。弱智+2
/* Telekinetic Forest Guard */
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef double DB;
const int maxn = 10005;
const DB eps = 1e-15;
int n, m;
inline int dcmp(DB x) {
if(fabs(x) < eps) return 0;
return x < 0 ? -1 : 1;
}
struct Vector {
DB x, y;
Vector(DB a = 0.0, DB b = 0.0) {
x = a; y = b;
}
Vector operator - (const Vector &A) const {
return Vector(x - A.x, y - A.y);
}
bool operator < (const Vector &A) const {
return fabs(x - A.x) > eps ? x < A.x : y < A.y;
}
bool operator == (const Vector &A) const {
return dcmp(x - A.x) == 0 && dcmp(y - A.y) == 0;
}
} p[maxn], cov[maxn];
typedef Vector Point;
inline DB Cross(Vector A, Vector B) {
return A.x * B.y - A.y * B.x;
}
inline void Andrew() {
sort(p + 1, p + 1 + n);
int k; m = 0;
k = 1;
for(int i = 1; i <= n; i++) {
for(; m > k && Cross(cov[m] - cov[m - 1], p[i] - cov[m - 1]) <= 0; m--);
cov[++m] = p[i];
}
k = m;
for(int i = n - 1; i; i--) {
for(; m > k && Cross(cov[m] - cov[m - 1], p[i] - cov[m - 1]) <= 0; m--);
cov[++m] = p[i];
}
}
inline DB getArea() {
DB res = 0.0;
for(int i = 2; i <= m; i++) res += Cross(cov[i - 1] - cov[1], cov[i] - cov[1]) / 2.0;
return res;
}
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
DB x, y; scanf("%lf%lf", &x, &y);
p[i] = Point(x, y);
}
Andrew();
printf("%d\n", (int)(getArea() / 50));
return 0;
}