题意是在二维平面上

给定n个人

每一个人的坐标和移动速度v

若对于某个点,仅仅有 x 能最先到达(即没有人能比x先到这个点或者同一时候到这个点)

则这个点称作被x占有

若有人能占有无穷大的面积 则输出1 。否则输出0

思路:

1、把全部点按速度排个序。然后把不是最大速度的点去掉

剩下的点才有可能是占有无穷大的面积

2、给速度最大的点做个凸包,则仅仅有在凸包上的点才有可能占有无穷大

若一个位置有多个人,则这几个人都是不能占有无穷大的。

凸包上边里共线的点是要保留的,,

附赠一波数据

#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
#define INF 999999999.9
#define PI acos(-1.0)
#define ll int
const int MAX_N = 507;
const double eps = 1e-6; struct Point {
int x, y, v;
int id;
Point () {}
Point (int _x, int _y, int _v, int _id) {
x = x, y = _y, v = _v, id = _id;
}
bool operator < (const Point &rhs) const {
if (x != rhs.x) return x < rhs.x;
return y < rhs.y;
}
}; int v[MAX_N];
bool vis[MAX_N];
int n, top;
int ans[MAX_N];
Point P[MAX_N], p1[MAX_N]; double cross(Point a, Point b, Point c) {
return (a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y);
} bool cmp(Point a, Point b) {
if (a.y == b.y) return a.x < b.x;
return a.y < b.y;
}
void graham() {
sort(p1, p1 + n, cmp);
top = 1;
for (int i = 0; i < 2; i++) v[i] = i;
for (int i = 2; i < n; i++) {
while (top > 0 && cross(p1[i], p1[v[top]], p1[v[top - 1]]) > 0) top--;
v[++top] = i;
}
int len = top;
v[++top] = n - 2;
for (int i = n - 3; i >= 0; i--) {
while (top > len && cross(p1[i], p1[v[top]], p1[v[top - 1]]) > 0) top--;
v[++top] = i;
}
} void Clear() {
memset(ans, 0, sizeof ans);
memset(p1, 0, sizeof p1);
memset(P, 0, sizeof P);
memset(v, 0, sizeof v);
memset(vis, 0, sizeof vis);
}
const int N = 505; struct E {
int x, y, v, id, ok;
}s[N];
vector<E> G;
bool cmp1(const E a, const E b) {
if(a.v != b.v) return a.v > b.v;
if(a.x != b.x) return a.x < b.x;
if(a.y != b.y) return a.y < b.y;
return a.id < b.id;
}
int nn;
void put(int ttop){
for(int i = 1; i <= nn; i ++) printf("%d", ans[i]);
puts("");
} int main() {
int cas = 0;
while(~scanf("%d", &nn), nn) {
Clear();
printf("Case #%d: ", ++cas);
memset(ans, 0, sizeof ans);
for(int i = 0; i < nn; i ++) {
scanf("%d%d%d", &s[i].x, &s[i].y, &s[i].v);
s[i].id = i+1;
s[i].ok = 1;
for(int j = 0; j < i; j++)
if(s[i].x==s[j].x && s[i].y==s[j].y && s[i].v==s[j].v)
{
s[i].ok = 0;
break;
}
}
sort(s, s + nn, cmp1);
if(s[0].v==0){put(12);continue;}
int ttop = 0;
while(ttop < nn && s[ttop].v == s[0].v) ttop ++;
//----------------------------
G.clear();
for(int i = 0; i < ttop; i++)if( s[i].ok ) G.push_back(s[i]);
bool gongxian = true;
int x = 0, y = 0;
for(int i = 1; i < ttop; i++)
{
if(s[i].x == s[i-1].x && s[i].y == s[i-1].y)continue;
if(x==0&&y==0) {
x = s[i].x-s[i-1].x;
y = s[i].y - s[i-1].y;
}
else if(s[i].x - s[i-1].x != x || s[i].y - s[i-1].y != y)
{
gongxian =false;
break;
}
}
if(G.size()<=2 || gongxian) {
for(int i = 0; i < G.size(); i++)
{
bool ok = true;
for(int j = 0; ok && j < ttop; j++)
if(G[i].id != s[j].id && G[i].x==s[j].x && G[i].y==s[j].y)
ok = false;
ans[G[i].id] = ok;
}
put(ttop); continue;
}
for(int i = 0; i < G.size(); i++)
{
p1[i].x = G[i].x;
p1[i].y = G[i].y;
p1[i].id = G[i].id;
}
n = G.size();
graham();
for(int i = 0; i <= top; i++)
{
bool ok = true;
for(int j = 0; ok && j < ttop; j++)
{
if(p1[v[i]].id != s[j].id && p1[v[i]].x==s[j].x && p1[v[i]].y==s[j].y)
ok = false;
}
ans[p1[v[i]].id] = ok;
}
put(ttop);
}
return 0;
}
/*
9
0 0 1
0 0 1
0 10 1
0 10 1
10 0 1
10 0 1
10 10 1
10 10 1
5 5 1 10
0 0 1
0 0 1
0 10 1
0 10 1
10 0 1
10 0 1
10 10 1
10 10 1
5 5 1
5 5 1 4
0 0 1
1 0 1
2 0 1
1 1 1 1
0 0 0 6
0 0 1
-1 0 1
1 0 1
0 1 1
0 -1 1
0 -1 1 6
0 0 1
-1 0 1
1 0 1
0 1 1
0 -1 1
0 -1 1 */

HDU 4946 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 (凸包,去重点,水平排序,留共线点)

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

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

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

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

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

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

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

  6. HDU 4946 Area of Mushroom 凸包

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

  7. HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)

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

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

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

  9. HDU 4946 共线凸包

    题目大意: 一些点在一张无穷图上面,每个点可以控制一些区域,这个区域满足这个点到达这个区域的时间严格小于其他点.求哪些点能够控制无穷面积的区域. 题目思路: 速度小的控制范围一定有限. 速度最大当且仅 ...

随机推荐

  1. Using TXMLDocument, Working with XML Nodes

    Using TXMLDocument The starting point for working with an XML document is the Xml.XMLDoc.TXMLDocumen ...

  2. win7 系统装SQLServer2000 成功

    昨天在win7上装SQLServer数据库,写一下体会.首先,如果以前安装的话,要删除干净.我也找了半天的网络资料.1.把原来SQLServer的安装目录 C:\Program Files\Micro ...

  3. 虚拟机安装android

    通过 虚拟机VirtualBox安装Android x86 4.0系统. Android x86是一个致力于让android运行在x86架构机器上的民间组织搞的项目,目前在世界上有很多人加入了它,虽然 ...

  4. Silverlight:《Pro Silverlight5》读书笔记 之 XAML

    XAML Properties and Events in XAML Simple Properties and Type Converters To bridge the gap between s ...

  5. 使用Struts2服务端与android交互

    转自:http://www.cnblogs.com/android-html5/archive/2011/09/25/2534107.html android--使用Struts2服务端与androi ...

  6. input输入框回车事件响应

    1.常用方法 1.方法1$('#applyCertNum').bind('keypress',function(event){ if(event.keyCode == 13) { alert('你输入 ...

  7. [Android 新特性] 改进明显 Android 4.4系统新特性解析

    Android 4.3发布半年之后,Android 4.4随着新一代Nexus5一起出现在了用户的面前,命名为从之前的Jelly Bean(果冻豆)换成了KitKat(奇巧).这个新系统究竟都有怎样的 ...

  8. LaTeX图片环境 Picture environment

    Picture environment If you need to include simple diagrams or figures in your document, the picture  ...

  9. MySQL模糊查询(like)时区分大小写

    问题说明:通过上面的语句,你会发现MySQL的like查询是不区分大小写的,因为我的失误,把Joe写成了joe才发现了这个东东吧.但是,有时候,我们需要区分大小写的是,该怎么办呢?解决方法如下: 方法 ...

  10. 5 cocos2dx 3.0源码分析 渲染 render

    渲染,感觉这个挺重要了,这里代入一个简单的例子 Sprite 建立及到最后的画在屏幕上, 我们描述一下这个渲染的流程:   1 sprite 初始化(纹理, 坐标,及当前元素的坐标大小信息) 2 主循 ...