题意是在二维平面上

给定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. Trigger a TTL circuit from ECL levels

    ECL circuits typically have relatively small logic spans of approximately 800 mV. Because of the sma ...

  2. PNP NPN NMOS PMOS S8050 S8550 SI2301 SI2302 2N3904 2N3906 78L05 TL431

  3. 禁止body滚动允许div滚动防微信露底

    最近遇到一个需求,页面中只有一个div允许滚动,其他内容不允许滚动. 正常来讲加上 body{height:100%;overflow: hidden;} 应该就阻止页面滚动了.可是很悲催的是手机端并 ...

  4. pytest文档6-fixture之yield实现teardown

    前言 上一篇讲到fixture通过scope参数控制setup级别,既然有setup作为用例之前前的操作,用例执行完之后那肯定也有teardown操作. 这里用到fixture的teardown操作并 ...

  5. 一个 forceLayout() 和 requestLayout() 的测试

    两个view: 一个是系统默认的FrameLayout,  A 一个是自己自定义的MyView extends View,重载了onMeasure函数(): B @Override protected ...

  6. Table里td中的文本过长,设置不换行,随内容同行显示(转载)

    当td中内容过长时,内容会溢出,换行显示,美观超级差,在td里设置这个属性 "white-space:nowrap   就可以解决排版问题啦 <td style="white ...

  7. 斯坦福大学卷积神经网络教程UFLDL Tutorial - Convolutional Neural Network

    Convolutional Neural Network Overview A Convolutional Neural Network (CNN) is comprised of one or mo ...

  8. 用Latex写IEEE论文

    如果在搞科研,想在IEEE上发表文章,那么就不得不用IEEE的论文模板,分为doc版本和Tex版本.Tex是高德纳·纳什所写,大牛级的任务,写过<计算机程序设计艺术>,曾经是美国最年轻的科 ...

  9. python -m xxx.py和python xxx.py的区别

    先看下python -m site作用是显示sys.path的值内容,也就是python搜索模块的目录,作用类似于linux下的PATH python -m SimpleHTTPServer 会在sy ...

  10. getaddrinfo详解

    #include <sys/socket.h> #include <netdb.h> int getaddrinfo(const char *restrict nodename ...