HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)
思路: 只有速度最大才有可能为1,速度不是最大肯定为0,那么就是 只需要操作那些速度最大的点,这些点求一个凸包,判断一下是不是在凸包边上即可。
有几个需要注意的地方:
1.最大速度如果为0 那么肯定所有都不行。
2.如果最大速度有重点那么 也都不行。
3.有些求凸包模板求出来的凸包可能有重点,要去重再求。
- #include<cstdio>
- #include<cstring>
- #include<algorithm>
- #include<cmath>
- #include<vector>
- #include <iostream>
- #define EPS 1e-8
- #define eps 1e-8
- using namespace std;
- struct TPoint
- {
- double x,y;
- int id,v;
- }p[],s[],hull[],pp[];
- double cross(TPoint a, TPoint b, TPoint c) {
- return (b.x - a.x) * (c.y - a.y) - (c.x - a.x)*(b.y - a.y);
- }
- double dis(TPoint a,TPoint b)
- {
- return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
- }
- bool graham_cmp(const TPoint &b, const TPoint &c) {
- double tmp = cross(b, c, p[]);
- if (tmp > EPS)
- return true;
- if (fabs(tmp) < EPS && (dis(b, p[]) < dis(c, p[])))
- return true;
- return false;
- }
- int graham_scan(TPoint hull[], int n) {
- int top, i, k = ;
- for (i = ; i < n; ++i)
- if ((p[k].y - p[i].y > EPS)
- || (fabs(p[i].y - p[k].y) < EPS && p[k].x - p[i].x > EPS))
- k = i;
- swap(p[], p[k]);
- sort(p + , p + n, graham_cmp);
- hull[] = p[], hull[] = p[], hull[] = p[];
- if (n < )
- return n;
- else
- top = ;
- for (i = ; i < n; ++i) {
- while (top >= && cross(hull[top - ], hull[top - ], p[i]) < EPS)
- --top;
- hull[top++] = p[i];
- }
- return top;
- }
- bool bo[];
- int ans[];
- bool cmp(TPoint a,TPoint b)
- {
- return a.x<b.x-eps||(fabs(a.x-b.x)<eps&&a.y<b.y);
- }
- int main() {
- int ri=,n;
- while(scanf("%d",&n)&&n)
- {
- int maxn=;
- for(int i=;i<n;++i)
- ans[i]=;
- for(int i=;i<n;++i)
- {
- scanf("%lf%lf%d",&s[i].x,&s[i].y,&s[i].v);
- s[i].id=i;
- maxn=std::max(maxn,s[i].v);
- }
- if(maxn==)
- {
- printf("Case #%d: ",++ri);
- for(int i=;i<n;++i)
- printf("");
- puts("");
- continue;
- }
- int tail=;
- for(int i=;i<n;++i)
- {
- if(s[i].v==maxn&&maxn>)
- {
- pp[tail]=s[i];
- p[tail++]=s[i];
- }
- }
- sort(p,p+tail,cmp);
- int kk=;
- for(int i=;i<tail;++i)
- if(i==tail-||fabs(p[i].x-p[i+].x)>eps||fabs(p[i].y-p[i+].y)>eps)
- p[kk++]=p[i];
- int h=graham_scan(hull,kk);
- hull[h]=hull[];
- for(int i=;i<tail;++i)
- {
- int flag=;
- for(int j=;j<tail;++j)
- if(i!=j&&fabs(pp[i].x-pp[j].x)<eps&&fabs(pp[i].y-pp[j].y)<eps)
- {
- flag=;
- break;
- }
- if(flag)
- {
- ans[pp[i].id]=;
- continue;
- }
- bool ok=false;
- for(int j=;j<h;++j)
- {
- if(fabs(cross(pp[i],hull[j],hull[j+]))<eps)
- ok=true;
- }
- if(ok)
- ans[pp[i].id]=;
- else
- ans[pp[i].id]=;
- }
- printf("Case #%d: ",++ri);
- for(int i=;i<n;++i)
- printf("%d",ans[i]);
- puts("");
- }
- }
HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)的更多相关文章
- hdu 4946 Area of Mushroom(凸包)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4946 Area of Mushroom Time Limit: 2000/1000 MS (Java/Ot ...
- HDU 4946 Area of Mushroom(构造凸包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4946 题目大意:在一个平面上有n个点p1,p2,p3,p4....pn,每个点可以以v的速度在平面上移 ...
- hdu 4946 Area of Mushroom (凸包,去重点,水平排序,留共线点)
题意: 在二维平面上,给定n个人 每个人的坐标和移动速度v 若对于某个点,只有 x 能最先到达(即没有人能比x先到这个点或者同时到这个点) 则这个点称作被x占有,若有人能占有无穷大的面积 则输出1 , ...
- HDU 4946 Area of Mushroom 凸包 第八次多校
题目链接:hdu 4946 题意:一大神有N个学生,各个都是小神,大神有个二次元空间,每一个小神都有一个初始坐标,如今大神把这些空间分给徒弟们,规则是假设这个地方有一个人比谁都先到这,那么这个地方就是 ...
- HDU 4946 Area of Mushroom 凸包
链接:pid=4946">http://acm.hdu.edu.cn/showproblem.php?pid=4946 题意:有n个人.在位置(xi,yi),速度是vi,假设对于某个点 ...
- HDU 4946 Area of Mushroom 共线凸包
题意是在二维平面上 给定n个人 每一个人的坐标和移动速度v 若对于某个点,仅仅有 x 能最先到达(即没有人能比x先到这个点或者同一时候到这个点) 则这个点称作被x占有 若有人能占有无穷大的面积 则输出 ...
- HDU 4946 Area of Mushroom (几何凸包)
题目链接 题意:给定n个人,每个人有一个速度v方向任意.如果平面中存在一个点只有某个人到达的时间最短(即没有人比这个人到的时间更短或相同),那么我们定义这个店归这个人管辖,现在问这些人中哪些人的管辖范 ...
- hdu 5003 模拟水题 (2014鞍山网赛G题)
你的一系列得分 先降序排列 再按0.95^(i-1)*ai 这个公式计算你的每一个得分 最后求和 Sample Input12530 478Sample Output984.1000000000 # ...
- 千寻浏览器 1.0 Beta 1(524)(2014年5月27日)
千寻浏览器--又一款新生浏览器今天进入各位浏览迷的视野.千寻浏览器基于IE内核,据传是由百度浏览器的上海团队操刀,在功能定位上,与目前的QQ浏览器有些相似. 千寻来自官方的解释:寻,追寻,探索,又是古 ...
随机推荐
- 类型转换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__()方法切返回值 ...
- 续并查集学习笔记——Gang团伙题解
一言不合先贴题目 Description 在某城市里住着n个人,任何两个认识的人不是朋友就是敌人,而且满足: 1. 我朋友的朋友是我的朋友: 2. 我敌人的敌人是我的朋友: 所有是朋友的人组成一个团伙 ...
- 微信小程序-媒体组件
audio 音频. MediaError.code 示例代码: <!-- audio.wxml --> <audio poster="{{poster}}" na ...
- Solr内置的字段类型
字段类型在org.apache.solr.schema包下 Class 描述 BCDIntField 二进制整形字段 BCDLongField 二进制长整形字段 BCDStrField 二进制字符型字 ...
- Mifare系列6-射频卡与读写器的通信(转)
文/闫鑫原创转载请注明出处http://blog.csdn.net/yxstars/article/details/38085415 1. 复位应答(Answer to request) 读写器呼叫磁 ...
- C#知识点总结系列:C# 数据结构
线性表(Linear List) 线性表是一个线性结构,它是一个含有n≥0个结点的有限序列,对于其中的结点,有且仅有一个开始结点没有前驱但有一个后继结点,有且仅有一个终端结点没有后继但有一个前驱结点, ...
- COG注释--转载
http://blog.sina.com.cn/s/blog_670445240102uxwy.html 一 COG简介 COG,即Clusters of Orthologous Groups of ...
- 需求:输入一个年份和月份 ,显示当前月日情况 ,星期数要对应准确 * 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 ...
- CSUOJ_1002
/* * Title : A+B(III) * Data : 2016/11/09 * Author : Andrew */ #include <iostream> #include &l ...
- django例子,question_text为中文时候报错
问题描述 UnicodeEncodeError at /admin/polls/question/3/ 'ascii' codec can't encode characters in positio ...