Teacher Mai has a kingdom with the infinite area.

He has n students guarding the kingdom.

The i-th student stands at the position (x i,y i), and his walking speed is v i.

If a point can be reached by a student, and the time this student walking to this point is strictly less than other students, this point is in the charge of this student.

For every student, Teacher Mai wants to know if the area in the charge of him is infinite.

Input

There are multiple test cases, terminated by a line "0".

For each test case, the first line contains one integer n(1<=n<=500).

In following n lines, each line contains three integers x i,y i,v i(0<=|x i|,|y i|,v i<=10^4).

Output

For each case, output "Case #k: s", where k is the case number counting from 1, and s is a string consisting of n character. If the area in the charge of the i-th student isn't infinite, the i-th character is "0", else it's "1".

Sample Input

3

0 0 3

1 1 2

2 2 1

0

Sample Output

Case #1: 100

题意是有n个人,每个人有一个坐标和速度,平面上如果的点如果他到达的时间严格的比其他任何人都快,那么这个点就属于他管辖。问每个人的管辖区域是不是无穷大。显然对于两个速度不同的人,速度小的人就不可能是无穷大。所以只需要找出速度最大的所有的人。先求出凸包,凸包的顶点是无穷大,然后找到所有凸包边上的点,这些点也可能是无穷大。然后暴力枚举所有的速度最大的点,如果和目前认为是无穷大的点重合,显然这两个重合点有相同速度到任何的点都是一样的时间,所以去掉。坑点是速度是0的点不可能无穷大。

wa了半天,我就是喜欢写代码bug

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iomanip>
#include<cmath>
#include<float.h>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define mm(x,b) memset((x),(b),sizeof(x))
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
typedef long long ll;
typedef long double ld;
typedef double db;
const ll mod=1e9+100;
const db e=exp(1);
const db eps=1e-8;
using namespace std;
const double pi=acos(-1.0);
const int INF=0xfffffff;
struct Point{
int x,y,num,temp1,temp2;
}p[1007],s[1007],a[1007];
int direction(Point p1,Point p2,Point p3)
{
return (p3.x-p1.x)*(p2.y-p1.y)-(p2.x-p1.x)*(p3.y-p1.y);
}//点2和3,按哪个和点一的角度更小排,相同的话按哪个更近排
double dis(Point p1,Point p2) { return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y)); }
bool cmp(Point p1,Point p2)//极角排序
{
int temp=direction(p[0],p1,p2);
if(temp<0)return true ;
if(temp==0&&dis(p[0],p1)<dis(p[0],p2))return true;
return false;
}
int Graham(int n)
{
int top;
int pos,minx,miny;
minx=miny=INF;
for(int i=0;i<n;i++)//找最下面的基点
if(p[i].y<miny||(p[i].y==miny&&p[i].x<minx))
{
minx=p[i].x;
miny=p[i].y;
pos=i;
}
swap(p[0],p[pos]);
sort(p+1,p+n,cmp);
p[n]=p[0];
s[0]=p[0];s[1]=p[1];s[2]=p[2];
top=2;
for(int i=3;i<=n;i++)
{
while(direction(s[top-1],s[top],p[i])>=0&&top>=2)top--;
s[++top]=p[i] ;
}
return top;
}
int main()
{
int n,ans=1;
while(1)
{
sf("%d",&n);
if(!n) return 0;
int Max=0;
rep(i,0,n)
{
a[i].temp1=0;a[i].temp2=0;
sf("%d%d%d",&a[i].x,&a[i].y,&a[i].num);
Max=max(Max,a[i].num);
}
if(Max==0)
{
pf("Case #%d: ",ans++);
rep(i,0,n)
pf("0");
pf("\n");
continue;
}
rep(i,0,n) if(a[i].num==Max) a[i].temp1=1;
rep(i,0,n)
{
if(a[i].num==Max)
rep(j,0,n)
{
if(i!=j&&a[j].num==Max&&a[i].x==a[j].x&&a[i].y==a[j].y)
{
a[i].temp1=0;a[j].temp1=0;
}
}
}
int sum=0;
rep(i,0,n)
{
if(a[i].num==Max)
{
int temp=0;
rep(j,0,sum)
if(a[i].x==p[j].x&&a[i].y==p[j].y)
temp=1;
if(temp==0)
p[sum++]=a[i];
}
}
int top;
top=Graham(sum);
rep(i,0,top)
{
rep(j,0,n)
{
if(s[i].x==a[j].x&&s[i].y==a[j].y)
a[j].temp2=1;
if(direction(s[i],s[(i+1)%top],a[j])==0)
a[j].temp2=1;
}
}
pf("Case #%d: ",ans++);
rep(i,0,n)
if(a[i].temp1&&a[i].temp2)
pf("1");
else
pf("0");
pf("\n");
}
}

D - Area of Mushroom的更多相关文章

  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(2014 Multi-University Training Contest 8)

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

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

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

  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 凸包 第八次多校

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

  7. HDU 4946 Area of Mushroom 共线凸包

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

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

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

  9. [hdu-4946] Area of Mushroom 计算几何 凸包

    大致题意: 平面上有n个人,给你每个人的坐标和一个速度v,如果某个人比其他所有人都先到达某点,则该点就被这个人掌控,求谁掌控者无限大的面积. 首先 速度最大的人,抛弃其他人,速度小的人必定无法得到无限 ...

随机推荐

  1. Socket编程的UDP与TCP,应用在哪些地方

    随着网络技术飞速发展,网速已不再是传输的瓶颈,UDP协议以其简单.传输快的优势,在越来越多场景下取代了TCP,如网页浏览.流媒体.实时游戏.物联网. 1,网速的提升给UDP稳定性提供可靠网络保障 CD ...

  2. iOS开发-装饰模式

    装饰模式是指在不必改变原类文件和使用继承的情况下,动态地扩展一个对象的功能.通过创建一个包装对象,也就是装饰来包裹真实的对象.装饰模式中的装饰对象和真实对象有相同的接口.这样客户端对象就能以和真实对象 ...

  3. js处理时间时区问题

    问题背景:服务器时间是东八区时间,页面会在全世界各地,页面 JS 功能需要对比服务器时间和用户本地时间,为兼容世界各地时间,需要将用户本地时间转换为东八区时间 一.基本概念 1.格林威治时间 格林威治 ...

  4. OAuth 2和JWT - 如何设计安全的API?

    OAuth 2和JWT - 如何设计安全的API? Moakap译,原文 OAuth 2 VS JSON Web Tokens: How to secure an API 本文会详细描述两种通用的保证 ...

  5. Java 迭代器综述

    一.摘要 迭代器模式是与集合共生共死的.一般来说.我们仅仅要实现一个容器,就须要同一时候提供这个容器的迭代器.使用迭代器的优点是:封装容器的内部实现细节,对于不同的集合,能够提供统一的遍历方式,简化c ...

  6. SNF快速开发平台--规则引擎整体介绍及使用说明书

    一.设计目标 a)规则引擎语法能够满足分单,计费,WMS策略的配置要求.语法是一致和统一的 b)能够在不修改规则引擎模块的情况下,加入任意一个新的规则:实现上述需求之外的规则配置需求 c)运算速度快 ...

  7. Atitit.每周计划日程表 流程表v3

    Atitit.每周计划日程表 流程表 每周趋势总结 新特性聚合  最佳实践聚合. 上周总结 本度计划 检查于推进年度计划月度计划里程碑 检查于推进季度计划月度计划里程碑 上周Todo汇总结转.. 待报 ...

  8. 无意识(无知)-->有意识-->进入潜意识-->无意识(本能状态)

    无意识(无知)-->有意识-->进入潜意识-->无意识(本能状态) 1. 从“无意识-->有意识”的两个重要内容是“反省”+“要努力学习”,估计有80%的人无法跨过这一步 2. ...

  9. 11款CSS3动画工具的开发

    本文展示了11个最好的和最令人惊异的CSS3动画工具,将为开发者是非常有帮助的.CSS3有设计师和开发人员之间的良好的声誉.它是在这里帮助他们创造惊人的结果. 有了这些动画工具,你可以创造一个轻松自由 ...

  10. java中的数据加密1 消息摘要

    消息摘要(Message Digest) 又称为数字摘要(Digital Digest).它是一个唯一对应一个消息或文本的固定长度的值,它由一个单向Hash加密函数对消息进行作用而产生.如果消息在途中 ...