3707: 圈地
来源:互联网 发布:梦想小镇淘宝充值 编辑:程序博客网 时间:2024/05/17 03:10
3707: 圈地
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 229 Solved: 85
[Submit][Status][Discuss]
Description
2维平面上有n个木桩,黄学长有一次圈地的机会并得到圈到的土地,为了体现他的高风亮节,他要使他圈到的土地面积尽量小。圈地需要圈一个至少3个点的多边形,多边形的顶点就是一个木桩,圈得的土地就是这个多边形内部的土地。(因为黄学长非常的神,所以他允许圈出的第n点共线,那样面积算0)
Input
第一行一个整数n,表示木桩个数。
接下来n行,每行2个整数表示一个木桩的坐标,坐标两两不同。
Output
仅一行,表示最小圈得的土地面积,保留2位小数。
Sample Input
3
0 0
0 1
1 0
0 0
0 1
1 0
Sample Output
0.50
HINT
对于100%的数据,n<=1000。
Source
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std; const int maxn = 1010;typedef double DB; struct Point{ DB x,y; Point(){} Point (DB x,DB y): x(x),y(y){} bool operator < (const Point &B) const { if (x < B.x) return 1; if (x > B.x) return 0; return y < B.y; } Point operator - (const Point &B) {return Point(x - B.x,y - B.y);}}p[maxn],q[maxn];typedef Point Vector; int n;DB Ans = 1E16; int max(const int &x,const int &y) {return x > y ? x : y;}DB Cross(const Vector &v1,const Vector &v2) {return v1.x * v2.y - v2.x * v1.y;} void Calc(int l,int r){ for (int i = l; i <= r; i++) for (int j = i + 1; j <= r; j++) for (int k = j + 1; k <= r; k++) Ans = min(Ans,fabs(Cross(q[j] - q[i],q[k] - q[i])));} int main(){ #ifdef DMC freopen("DMC.txt","r",stdin); #endif cin >> n; int siz = 50; for (int i = 1; i <= n; i++) scanf("%lf%lf",&p[i].x,&p[i].y); for (int I = 0; I < 100; I++) { DB alpha = (DB)(rand() - rand()) / 233.00; DB Cos = cos(alpha),Sin = sin(alpha); //printf("%.8lf %.8lf\n",Cos,Sin); for (int i = 1; i <= n; i++) q[i] = Point(p[i].x * Cos - p[i].y * Sin,p[i].x * Sin + p[i].y * Cos); sort(q + 1,q + n + 1); int last = 1,tot = 0; for (int i = 1; i <= n; i++) { ++tot; if (tot == siz || i == n) Calc(last,i),tot = 0,last = i + 1; } } printf("%.2f\n",Ans / 2.00); return 0;}
0 0
- 3707: 圈地
- BZOJ 3707 圈地
- BZOJ 3707: 圈地 (动态凸包)
- BZOJ3707 圈地
- 圈地计划
- 圈地问题
- BZOJ3707: 圈地
- 圈地运动了一回
- 圈地为王示例
- 【BZOJ 2132】 圈地计划
- bzoj 2132: 圈地计划
- hihocoder #1042 : 跑马圈地
- bzoj-3232 圈地游戏
- [bzoj2132]圈地计划
- BZOJ2132: 圈地计划
- bzoj2132 圈地计划
- bzoj 2132: 圈地计划
- BZOJ3232: 圈地游戏
- 反思与总结:破壳篇
- 求链表最大节点的前驱结点
- Spring Session
- 代理模式
- 2017-01-30
- 3707: 圈地
- Leetcode 64. Minimum Path Sum
- 3 帮助命令、用户管理、压缩
- 2655: calc
- sort按vector元素排序
- 483. Smallest Good Base
- sort关键字排序
- 递归程序复杂度计算->主定理
- DRAM,SRAM,SDRAM的关系与区别