[hdu-4946] Area of Mushroom 计算几何 凸包
大致题意:
平面上有n个人,给你每个人的坐标和一个速度v,如果某个人比其他所有人都先到达某点,则该点就被这个人掌控,求谁掌控者无限大的面积。
首先 速度最大的人,抛弃其他人,速度小的人必定无法得到无限的面积。
然后 所有速度最大的人建凸包,则凸包上节点的人和凸包边上的人必定有无限的面积,凸包内部的人必定没有,因为速度都相等。
ps:建凸包时不能直接将叉积的<=该为<来构建边上有点的凸包,因为有重点。
最后将所有得到的人中有重合的全部去除,最后留下的人掌控的面积无限
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 100100
#define eps 1e-9
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fre freopen
#define pi acos(-1.0)
#define inf 1e6+7
#define Vector Point
const int Mod=1e9+;
typedef unsigned long long ull;
typedef long long ll;
int dcmp(double x){
if(fabs(x)<=eps) return ;
return x<?-:;
}
struct Point{
double x,y;
int v;
int id;
Point(double x=,double y=):x(x),y(y) {}
bool operator < (const Point &a)const{
if(x==a.x && y==a.y) return v<a.v;
if(x==a.x) return y<a.y;
return x<a.x;
}
Point operator - (const Point &a)const{
return Point(x-a.x,y-a.y);
}
Point operator + (const Point &a)const{
return Point(x+a.x,y+a.y);
}
Point operator * (const double &a)const{
return Point(x*a,y*a);
}
Point operator / (const double &a)const{
return Point(x/a,y/a);
}
void read(){
scanf("%lf%lf",&x,&y);
scanf("%d",&v);
}
void out(){
cout<<"debug: "<<x<<" "<<y<<endl;
}
bool operator == (const Point &a)const{
return dcmp(x-a.x)== && dcmp(y-a.y)==;
}
bool operator !=(const Point &a)const{
return dcmp(x-a.x)!= || dcmp(y-a.y)!=;
}
};
double Dot(Vector a,Vector b) {
return a.x*b.x+a.y*b.y;
}
double dis(Vector a) {
return Dot(a,a);
}
double Cross(Point a,Point b){
return a.x*b.y-a.y*b.x;
}
bool cmp(Point a,Point b){
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
int vt[];
int ConvexHull(Point *p,int n,Point *ch,int maxv){
sort(p,p+n,cmp);
int m=;
for(int i=;i<n;i++){
while(m> && Cross(ch[m-]-ch[m-],p[i]-ch[m-])<=) m--;
ch[m++]=p[i];
}
int k=m;
for(int i=n-;i>=;i--){
while(m>k && Cross(ch[m-]-ch[m-],p[i]-ch[m-])<=) m--;
ch[m++]=p[i];
}
if(n>) m--;
return m;
}
int n;
Point p[];
Point ch[];
Point pp[];
char s[];
void solve(){
met(vt,);
int maxv=;
s[n]='\0';
int rt=;
For(i,,n-) s[i]='';
For(i,,n-) p[i].read(),p[i].id=i;
sort(p,p+n);
For(i,,n-) {
if(p[i]==p[i-] && p[i].v==p[i-].v) vt[p[i].id]=,vt[p[i-].id]=;
}
For(i,,n-) maxv=max(maxv,p[i].v);
For(i,,n-) if(p[i].v==maxv) pp[rt++]=p[i];
if(maxv==){
puts(s);
return ;
}
int m=ConvexHull(pp,rt,ch,maxv);
For(i,,m-){
if(!vt[ch[i].id]) s[ch[i].id]='';
}
For(i,,rt-) {
// cout<<"Bug: "<<pp[i].id<<" "<<vt[pp[i].id]<<endl;
// pp[i].out();
For(j,,m-){
if(dcmp(Cross(ch[j]-pp[i],ch[(j+)%m]-pp[i]))== && !vt[pp[i].id]) {s[pp[i].id]='';break;}
}
}
puts(s);
}
int main(){
// fre("in.txt","r",stdin);
int t=;
while(~scanf("%d",&n) && n) printf("Case #%d: ",++t),solve();
return ;
}
[hdu-4946] Area of Mushroom 计算几何 凸包的更多相关文章
- 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 (几何凸包)
题目链接 题意:给定n个人,每个人有一个速度v方向任意.如果平面中存在一个点只有某个人到达的时间最短(即没有人比这个人到的时间更短或相同),那么我们定义这个店归这个人管辖,现在问这些人中哪些人的管辖范 ...
- HDU 4946 Area of Mushroom 共线凸包
题意是在二维平面上 给定n个人 每一个人的坐标和移动速度v 若对于某个点,仅仅有 x 能最先到达(即没有人能比x先到这个点或者同一时候到这个点) 则这个点称作被x占有 若有人能占有无穷大的面积 则输出 ...
- hdu 4946 Area of Mushroom (凸包,去重点,水平排序,留共线点)
题意: 在二维平面上,给定n个人 每个人的坐标和移动速度v 若对于某个点,只有 x 能最先到达(即没有人能比x先到这个点或者同时到这个点) 则这个点称作被x占有,若有人能占有无穷大的面积 则输出1 , ...
- HDU 4946 Area of Mushroom 凸包 第八次多校
题目链接:hdu 4946 题意:一大神有N个学生,各个都是小神,大神有个二次元空间,每一个小神都有一个初始坐标,如今大神把这些空间分给徒弟们,规则是假设这个地方有一个人比谁都先到这,那么这个地方就是 ...
- 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 凸包
链接:pid=4946">http://acm.hdu.edu.cn/showproblem.php?pid=4946 题意:有n个人.在位置(xi,yi),速度是vi,假设对于某个点 ...
- HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)
思路: 只有速度最大才有可能为1,速度不是最大肯定为0,那么就是 只需要操作那些速度最大的点,这些点求一个凸包,判断一下是不是在凸包边上即可. 有几个需要注意的地方: 1.最大速度如果为0 那么肯 ...
- hdu 1451 Area in Triangle(计算几何 三角形)
Given a triangle field and a rope of a certain length (Figure-1), you are required to use the rope t ...
随机推荐
- spring和Quartz的集群(二)
一:前沿 写完了这两篇才突然想起来,忘记了最关键的东西,那就是在配置文件这里的配置,还有数据库的配置.这是郁闷啊!继续吧! 二:内容配置 我们在集成的时候需要自己配置一个quartz.properti ...
- UVA 12716 GCD XOR
https://vjudge.net/problem/UVA-12716 求有多少对整数(a,b)满足:1<=b<=a<=n,且gcd(a,b)=a XOR b 结论:若gcd(a, ...
- C11简洁之道:函数绑定
1. 可调用对象 在C++中,有“可调用对象”这么个概念,那么什么是调用对象呢?有哪些情况?我们来看看: 函数指针: 具有operator()成员函数的类对象(仿函数): 可以被转换为函数指针的类对 ...
- struts2常用标签之数据标签
数据标签1 property标签 property标签的主要属性: value:用来获取值的OGNL表达式,如果value属性值没有指定,那么将会被设定为top,也就是返回位于值栈最顶端的对象. ...
- Jenkins Pulgin 安装
1. 利用管理插件找到需要安装的插件. 2. 如果安装失败,查看缺少啥. 3. 手动去下载http://updates.jenkins-ci.org/download/plugins/ 4. 安装此插 ...
- hdu5909 Tree Cutting
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5909 [题解] 设$f_{x,i}$表示以$x$节点的子树中,权值为$i$的子树个数,其中$x$必选. ...
- node起本地服务器以及实现代理,前端接口转发
上一篇文章写了使用docker来做nginx镜像实现本地的页面代理以及接口转发,但是需要下载docker,这个对于很多人来说还是显得比较麻烦,于是这个文章就是介绍如何只用node就可以代理本地的页面和 ...
- 基于ansj_seg和nlp-lang的简单nlp工具类
1.首先在pom中引入ansj_seg和nlp-lang的依赖包, ansj_seg包的作用: 这是一个基于n-Gram+CRF+HMM的中文分词的java实现: 分词速度达到每秒钟大约200万字左右 ...
- github删除文件夹
git rm -rf dirgit add .git commit -m 'remove dir'git push origin master //dir是要删除的文件夹路径
- 自动化测试===unittest和requests接口测试案例,测试快递查询api(二)
在原来基础上生成测试报告: 首先需要 HTMLTestRunner.py 的unittest生成报告文件 (源码,自动化测试===unittest配套的HTMLTestRunner.py生成html ...