链接:http://acm.hdu.edu.cn/showproblem.php?pid=4946

题意:有n个人。在位置(xi,yi),速度是vi,假设对于某个点一个人比全部其它的都能先到那个点,那这个点就被这个人承包了。输出有多少人承包的(鱼塘)面积是无穷大。

思路:找出速度最大值,仅仅有速度是这个最大值的人才有可能承包无穷大的面积(由于快速者早晚会追上低速者)。

每两个人相比,他们能承包的位置的界线是他们坐标的中垂线,能够证明的是,在组成凸包时,在凸包里的人。承包的面积一定是有限的。

所以在凸包上的人(包含边上)才可能承包无穷大的面积。

注意点在于由于题里要求严格小于其它人到达的时间才干承包,所以假设出现重点重速的两个人,那么两个人都是不能承包的,可是在计算凸包时它们须要计进来由于有可能由于他们的存在导致其它人承包不了。

代码:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define eps 1e-10
#define INF 0x7fffffff
#define maxn 10005
#define PI acos(-1.0)
#define seed 31//131,1313
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
int x[505],y[505],v[505],vis[505];
int cmp(double x)
{if(fabs(x)<eps)return 0;if(x>0)return 1;return -1;
}
inline double sqr(double x)
{return x*x;
}
struct point//点
{double x,y;int pos;int o;point() {}point(double a,double b):x(a),y(b) {}void input(){scanf("%lf%lf",&x,&y);}friend point operator + (const point &a,const point &b){return point(a.x+b.x,a.y+b.y);}friend point operator - (const point &a,const point &b){return point(a.x-b.x,a.y-b.y);}friend bool operator == (const point &a,const point &b){return cmp(a.x-b.x)==0 &&cmp(a.y-b.y)==0;}friend point operator * (const point &a,const double &b){return point(a.x*b,a.y*b);}friend point operator * (const double &a,const point &b){return point(a*b.x,a*b.y);}friend point operator / (const point &a,const double &b){return point(a.x/b,a.y/b);}double norm(){return sqrt(sqr(x)+sqr(y));}//到原点距离void out () const{printf("%.2f %.2f",x,y);}
} p[505];
double det (const point &a,const point &b)
{return a.x*b.y-a.y*b.x;
}//叉积
double dot (const point &a,const point &b)
{return a.x*b.x+a.y*b.y;
}//点乘
double dist (const point &a,const point &b)
{return (a-b).norm();
}//距离
point rotate_point(const point &p,double A)
{double tx=p.x,ty=p.y;return point (tx*cos(A)-ty*sin(A),tx*sin(A)+ty*cos(A));
}//旋转,A是弧度
struct polygon_convex
{vector <point> P;polygon_convex(int size=0){P.resize(size);}
} p_c;
bool comp_less(const point &a,const point &b)
{return cmp(a.x-b.x)<0||cmp(a.x-b.x)==0&&cmp(a.y-b.y)<0;
}
polygon_convex convex_hull(vector <point> a)
{polygon_convex res(2*a.size()+5);sort(a.begin(),a.end(),comp_less);a.erase(unique(a.begin(),a.end()),a.end());int m=0;for(int i=0; i<a.size(); i++){while(m>1 && cmp(det(res.P[m-1]-res.P[m-2],a[i]-res.P[m-2]))<0)m--;res.P[m++]=a[i];}int k=m;for(int i=int(a.size())-2; i>=0; i--){while(m>k && cmp(det(res.P[m-1]-res.P[m-2],a[i]-res.P[m-2]))<0)m--;res.P[m++]=a[i];}res.P.resize(m);if(a.size()>1)res.P.resize(m-1);return res;
}
bool cmp3(point a,point b)
{return a.x<b.x||((a.x==b.x)&&(a.y<b.y));
}
int main()
{int T,tt=0;while(scanf("%d",&T)){tt++;vector<point>pp;pp.clear();memset(vis,0,sizeof(vis));if(T==0)break;int pos=-1;int max_v=0;for(int i=1; i<=T; i++){scanf("%d%d%d",&x[i],&y[i],&v[i]);if(v[i]>max_v)max_v=v[i];}int top=0;for(int i=1; i<=T; i++){if(v[i]==max_v){p[top].x=(double)x[i];p[top].y=(double)y[i];p[top].pos=i;p[top].o=0;top++;}}printf("Case #%d: ",tt);if(max_v==0){for(int i=1; i<=T; i++)printf("0");printf("\n");continue;}sort(p,p+top,cmp3);for(int i=0; i<top; i++){if((i<top-1&&(p[i].x)==(p[i+1].x)&&(p[i].y)==(p[i+1].y))||(i>0&&(p[i].x)==(p[i-1].x)&&(p[i].y)==(p[i-1].y)))p[i].o=1;}pp.push_back(p[0]);for(int i=1; i<top; i++){if(p[i].x!=p[i-1].x||p[i].y!=p[i-1].y)pp.push_back(p[i]);}if(pp.size()<=3){for(int i=0; i<pp.size(); i++)if(pp[i].o==0)vis[pp[i].pos]=1;}else{polygon_convex ans=convex_hull(pp);for(int i=0; i<ans.P.size(); i++){if(ans.P[i].o==0)vis[ans.P[i].pos]=1;}}for(int i=1; i<=T; i++)printf("%d",vis[i]);printf("\n");}return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

转载于:https://www.cnblogs.com/mfrbuaa/p/4726900.html

HDU 4946 Area of Mushroom 凸包相关推荐

  1. HDU 4946 Area of Mushroom 凸包 第八次多校

    题目链接:hdu 4946 题意:一大神有N个学生,各个都是小神,大神有个二次元空间,每一个小神都有一个初始坐标,如今大神把这些空间分给徒弟们,规则是假设这个地方有一个人比谁都先到这,那么这个地方就是 ...

  2. hdu 4946 凸包注意重点

    http://acm.hdu.edu.cn/showproblem.php?pid=4946 给你n个点的坐标和速度,如果一个点能够到达无穷远处,且花费的时间是最少的,则此点输出1,否则输出0. 每个 ...

  3. HDU 3934 Summer holiday(凸包内接最大三角形)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3934 题意:给出n个点,从中找出三个点使得面积最大. 思路:旋转卡壳模板题:首先求凸包,在旋转求最大面 ...

  4. HDU 6617 Enveloping Convex(凸包+半平面交+二分)

    首先对于这m个点维护出一个凸包M,那么问题就变成了判断凸包P进行放大缩小能不能包含凸包M.(凸包P可以进行中心对称变换再进行放大缩小,见题意) 如何判断合适的相似比呢,我们可以用二分去放大缩小凸包P的 ...

  5. HDU 2202 最大三角形 (凸包)

    Description 老师在计算几何这门课上给Eddy布置了一道题目,题目是这样的:给定二维的平面上n个不同的点,要求在这些点里寻找三个点,使他们构成的三角形拥有的面积最大. Eddy对这道题目百思 ...

  6. 全国各省市区数据sql格式(utf8)

    一.省 DROP TABLE IF EXISTS `provinces`; CREATE TABLE `provinces` ( `id` int(11) NOT NULL auto_incremen ...

  7. HDU 3662 3D Convex Hull(三维凸包面的个数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3662 题意:求三维凸包面的个数. 思路:模板. struct Point {double x,y,z; ...

  8. HDU 5928 DP 凸包graham

    给出点集,和不大于L长的绳子,问能包裹住的最多点数. 考虑每个点都作为左下角的起点跑一遍极角序求凸包,求的过程中用DP记录当前以j为当前末端为结束的的最小长度,其中一维作为背包的是凸包内侧点的数量.也 ...

  9. 二维凸包(模板) hdu 1348 求凸包的周长

    题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1348 凸包模板: const int N =1010; const double PI = 3.141 ...

最新文章

  1. 第一个 Mybatis 程序(CURD操作)
  2. 4.12Python数据处理篇之Matplotlib系列(十二)---绘图风格的介绍
  3. Superset配置impala数据源
  4. DLL入门浅析(2)——如何使用DLL
  5. 互联网晚报 | 4月13日 星期三 | 阿里云人事大变动;老坛酸菜方便面重返超市货架;工信部:加快5G全连接工厂建设...
  6. web导入excel数据
  7. mysql 字符串特殊字符_转:MySQL数据入库时特殊字符处理
  8. python35个关键字_Python关键字35个
  9. qwt的安装和移植-
  10. 45:十进制到八进制
  11. P2966 [USACO09DEC]牛收费路径Cow Toll Paths
  12. C#语法基础(三)----窗体设计
  13. mysql libaio_手动编译安装mysql,报错没有libaio模块,
  14. 1983年图灵奖--肯尼斯·汤普森和丹尼斯·里奇简介
  15. 带计算机功能的私有云,网盘关停不用愁 教你打造个人私有云
  16. Windows 10桌面空白处鼠标右键转圈
  17. 无线AP Aruba-515初始化设置
  18. 解决oracle出现the account is locked问题以及出现not logged on
  19. Burp Suite 实战指南
  20. Python之读取MongoDB导出的BSON文件

热门文章

  1. [Python基础]003.语法(2)
  2. java调用存储过程
  3. asp.net 获取 当前日期时间 及 前后N天日期时间(DropDownList数据绑定)
  4. 将MATLAB的变量数据导入到C/C++程序中的方法
  5. python plot 坐标轴范围,Python,Matplotlib,子图:如何设置轴范围?
  6. 32 墨水屏股票显示器_炒股护眼新选择 | 电子墨水显示器amp;平板盯盘效果(附视频)...
  7. leetcode算法题--石子游戏
  8. php 对象里还有哪些对象_PHP面向对象(OOP)之实例化对象的方法
  9. php 5.6 新特性,PHP5.6新特性介绍
  10. Java反射之如何判断类或变量、方法的修饰符(Modifier解析)