思路: 只有速度最大才有可能为1,速度不是最大肯定为0,那么就是 只需要操作那些速度最大的点,这些点求一个凸包,判断一下是不是在凸包边上即可。

有几个需要注意的地方:

1.最大速度如果为0   那么肯定所有都不行。

2.如果最大速度有重点那么 也都不行。

3.有些求凸包模板求出来的凸包可能有重点,要去重再求。

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<algorithm>
  4. #include<cmath>
  5. #include<vector>
  6. #include <iostream>
  7. #define EPS 1e-8
  8. #define eps 1e-8
  9. using namespace std;
  10. struct TPoint
  11. {
  12. double x,y;
  13. int id,v;
  14. }p[],s[],hull[],pp[];
  15. double cross(TPoint a, TPoint b, TPoint c) {
  16. return (b.x - a.x) * (c.y - a.y) - (c.x - a.x)*(b.y - a.y);
  17. }
  18. double dis(TPoint a,TPoint b)
  19. {
  20. return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
  21. }
  22. bool graham_cmp(const TPoint &b, const TPoint &c) {
  23. double tmp = cross(b, c, p[]);
  24. if (tmp > EPS)
  25. return true;
  26. if (fabs(tmp) < EPS && (dis(b, p[]) < dis(c, p[])))
  27. return true;
  28. return false;
  29. }
  30. int graham_scan(TPoint hull[], int n) {
  31. int top, i, k = ;
  32. for (i = ; i < n; ++i)
  33. if ((p[k].y - p[i].y > EPS)
  34. || (fabs(p[i].y - p[k].y) < EPS && p[k].x - p[i].x > EPS))
  35. k = i;
  36. swap(p[], p[k]);
  37. sort(p + , p + n, graham_cmp);
  38. hull[] = p[], hull[] = p[], hull[] = p[];
  39. if (n < )
  40. return n;
  41. else
  42. top = ;
  43. for (i = ; i < n; ++i) {
  44. while (top >= && cross(hull[top - ], hull[top - ], p[i]) < EPS)
  45. --top;
  46. hull[top++] = p[i];
  47. }
  48. return top;
  49. }
  50. bool bo[];
  51. int ans[];
  52. bool cmp(TPoint a,TPoint b)
  53. {
  54. return a.x<b.x-eps||(fabs(a.x-b.x)<eps&&a.y<b.y);
  55. }
  56. int main() {
  57. int ri=,n;
  58. while(scanf("%d",&n)&&n)
  59. {
  60. int maxn=;
  61. for(int i=;i<n;++i)
  62. ans[i]=;
  63. for(int i=;i<n;++i)
  64. {
  65. scanf("%lf%lf%d",&s[i].x,&s[i].y,&s[i].v);
  66. s[i].id=i;
  67. maxn=std::max(maxn,s[i].v);
  68. }
  69. if(maxn==)
  70. {
  71. printf("Case #%d: ",++ri);
  72. for(int i=;i<n;++i)
  73. printf("");
  74. puts("");
  75. continue;
  76. }
  77. int tail=;
  78. for(int i=;i<n;++i)
  79. {
  80. if(s[i].v==maxn&&maxn>)
  81. {
  82. pp[tail]=s[i];
  83. p[tail++]=s[i];
  84. }
  85. }
  86. sort(p,p+tail,cmp);
  87. int kk=;
  88. for(int i=;i<tail;++i)
  89. if(i==tail-||fabs(p[i].x-p[i+].x)>eps||fabs(p[i].y-p[i+].y)>eps)
  90. p[kk++]=p[i];
  91. int h=graham_scan(hull,kk);
  92. hull[h]=hull[];
  93. for(int i=;i<tail;++i)
  94. {
  95. int flag=;
  96. for(int j=;j<tail;++j)
  97. if(i!=j&&fabs(pp[i].x-pp[j].x)<eps&&fabs(pp[i].y-pp[j].y)<eps)
  98. {
  99. flag=;
  100. break;
  101. }
  102. if(flag)
  103. {
  104. ans[pp[i].id]=;
  105. continue;
  106. }
  107. bool ok=false;
  108. for(int j=;j<h;++j)
  109. {
  110. if(fabs(cross(pp[i],hull[j],hull[j+]))<eps)
  111. ok=true;
  112. }
  113. if(ok)
  114. ans[pp[i].id]=;
  115. else
  116. ans[pp[i].id]=;
  117. }
  118. printf("Case #%d: ",++ri);
  119. for(int i=;i<n;++i)
  120. printf("%d",ans[i]);
  121. puts("");
  122.  
  123. }
  124. }

HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)的更多相关文章

  1. hdu 4946 Area of Mushroom(凸包)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4946 Area of Mushroom Time Limit: 2000/1000 MS (Java/Ot ...

  2. HDU 4946 Area of Mushroom(构造凸包)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4946 题目大意:在一个平面上有n个点p1,p2,p3,p4....pn,每个点可以以v的速度在平面上移 ...

  3. hdu 4946 Area of Mushroom (凸包,去重点,水平排序,留共线点)

    题意: 在二维平面上,给定n个人 每个人的坐标和移动速度v 若对于某个点,只有 x 能最先到达(即没有人能比x先到这个点或者同时到这个点) 则这个点称作被x占有,若有人能占有无穷大的面积 则输出1 , ...

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

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

  5. HDU 4946 Area of Mushroom 凸包

    链接:pid=4946">http://acm.hdu.edu.cn/showproblem.php?pid=4946 题意:有n个人.在位置(xi,yi),速度是vi,假设对于某个点 ...

  6. HDU 4946 Area of Mushroom 共线凸包

    题意是在二维平面上 给定n个人 每一个人的坐标和移动速度v 若对于某个点,仅仅有 x 能最先到达(即没有人能比x先到这个点或者同一时候到这个点) 则这个点称作被x占有 若有人能占有无穷大的面积 则输出 ...

  7. HDU 4946 Area of Mushroom (几何凸包)

    题目链接 题意:给定n个人,每个人有一个速度v方向任意.如果平面中存在一个点只有某个人到达的时间最短(即没有人比这个人到的时间更短或相同),那么我们定义这个店归这个人管辖,现在问这些人中哪些人的管辖范 ...

  8. hdu 5003 模拟水题 (2014鞍山网赛G题)

    你的一系列得分 先降序排列 再按0.95^(i-1)*ai 这个公式计算你的每一个得分 最后求和 Sample Input12530 478Sample Output984.1000000000 # ...

  9. 千寻浏览器 1.0 Beta 1(524)(2014年5月27日)

    千寻浏览器--又一款新生浏览器今天进入各位浏览迷的视野.千寻浏览器基于IE内核,据传是由百度浏览器的上海团队操刀,在功能定位上,与目前的QQ浏览器有些相似. 千寻来自官方的解释:寻,追寻,探索,又是古 ...

随机推荐

  1. 类型转换bin()、chr()、ord() 、int()、float()、str()、repr()、bytes()、tuple(s )、 list(s )   、unichr(x ) 、 ord(x )  、 hex(x )  、          type()数据类型查询

    1.bin() 将整数x转换为二进制字符串,如果x不为Python中int类型,x必须包含方法__index__()并且返回值为integer: 参数x:整数或者包含__index__()方法切返回值 ...

  2. 续并查集学习笔记——Gang团伙题解

    一言不合先贴题目 Description 在某城市里住着n个人,任何两个认识的人不是朋友就是敌人,而且满足: 1. 我朋友的朋友是我的朋友: 2. 我敌人的敌人是我的朋友: 所有是朋友的人组成一个团伙 ...

  3. 微信小程序-媒体组件

    audio 音频. MediaError.code 示例代码: <!-- audio.wxml --> <audio poster="{{poster}}" na ...

  4. Solr内置的字段类型

    字段类型在org.apache.solr.schema包下 Class 描述 BCDIntField 二进制整形字段 BCDLongField 二进制长整形字段 BCDStrField 二进制字符型字 ...

  5. Mifare系列6-射频卡与读写器的通信(转)

    文/闫鑫原创转载请注明出处http://blog.csdn.net/yxstars/article/details/38085415 1. 复位应答(Answer to request) 读写器呼叫磁 ...

  6. C#知识点总结系列:C# 数据结构

    线性表(Linear List) 线性表是一个线性结构,它是一个含有n≥0个结点的有限序列,对于其中的结点,有且仅有一个开始结点没有前驱但有一个后继结点,有且仅有一个终端结点没有后继但有一个前驱结点, ...

  7. COG注释--转载

    http://blog.sina.com.cn/s/blog_670445240102uxwy.html 一 COG简介 COG,即Clusters of Orthologous Groups of ...

  8. 需求:输入一个年份和月份 ,显示当前月日情况 ,星期数要对应准确 * 1.1900年1月1号开始 * 2.星期 : 直接用总天数对7求余数 31 28 59 / 7 = 5 * 3.以\t来个开

    public class Demo4 { /** * @param args */ public static void main(String[] args) { // TODO Auto-gene ...

  9. CSUOJ_1002

    /* * Title : A+B(III) * Data : 2016/11/09 * Author : Andrew */ #include <iostream> #include &l ...

  10. django例子,question_text为中文时候报错

    问题描述 UnicodeEncodeError at /admin/polls/question/3/ 'ascii' codec can't encode characters in positio ...