Triathlon
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 6461   Accepted: 1643

Description

Triathlon is an athletic contest consisting of three consecutive sections that should be completed as fast as possible as a whole. The first section is swimming, the second section is riding bicycle and the third one is running.

The speed of each contestant in all three sections is known. The judge can choose the length of each section arbitrarily provided that no section has zero length. As a result sometimes she could choose their lengths in such a way that some particular contestant would win the competition.

Input

The first line of the input file contains integer number N (1 <= N <= 100), denoting the number of contestants. Then N lines follow, each line contains three integers Vi, Ui and Wi (1 <= Vi, Ui, Wi <= 10000), separated by spaces, denoting the speed of ith contestant in each section.

Output

For every contestant write to the output file one line, that contains word "Yes" if the judge could choose the lengths of the sections in such a way that this particular contestant would win (i.e. she is the only one who would come first), or word "No" if this is impossible.

Sample Input

9
10 2 6
10 7 3
5 6 7
3 2 7
6 2 6
3 5 7
8 4 6
10 4 2
1 8 7

Sample Output

Yes
Yes
Yes
No
No
No
Yes
No
Yes
/*
poj 1755 半平面交+不等式 一个比赛分三个部分,每个人在三个部分的速度为U,V,W。每个赛道的长度不一定。
现在给你n个人的情况,问他们是否能得奖 总时间 t1 = x/u1+y/v1+z/w1 t2 = x/u2+y/v2+z/w2
那么 两个人的时间差 t = t1 - t2 = ax+by+cz,判断正负即可
所以 可以看成 (a/z)x+(b/z)y+c 就成了二元方程
然后利用半平面相交计算出这些不等式最后能否得到一个>0公共区域。
如果能,则说明冠军与你有缘诶 hhh-2016-05-17 22:32:51
*/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <cstdio>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;
#define lson (i<<1)
#define rson ((i<<1)|1)
typedef long long ll;
using namespace std;
const int maxn = 300;
const double PI = 3.1415926;
const double eps = 1e-16;
int n;
int sgn(double x)
{
if(fabs(x) < eps) return 0;
if(x < 0)
return -1;
else
return 1;
} struct Point
{
double x,y;
Point() {}
Point(double _x,double _y)
{
x = _x,y = _y;
}
Point operator -(const Point &b)const
{
return Point(x-b.x,y-b.y);
}
double operator ^(const Point &b)const
{
return x*b.y-y*b.x;
}
double operator *(const Point &b)const
{
return x*b.x + y*b.y;
}
}; struct Line
{
Point s,t;
double k;
Line() {}
Line(Point _s,Point _t)
{
s = _s;
t = _t;
k = atan2(t.y-s.y,t.x-s.x);
}
Point operator &(const Line &b) const
{
Point res = s;
double ta = ((s-b.s)^(b.s-b.t))/((s-t)^(b.s-b.t));
res.x += (t.x-s.x)*ta;
res.y += (t.y-s.y)*ta;
return res;
}
}; //求p1,p2的直线与a,b,c这条直线的交点
Point Intersection(Point p1,Point p2,double a,double b,double c)
{
double u = fabs(a*p1.x + b*p1.y + c);
double v = fabs(a*p2.x + b*p2.y + c);
Point t;
t.x = (p1.x*v + p2.x*u)/(u+v);
t.y = (p1.y*v + p2.y*u)/(u+v);
return t;
} double CalArea(Point p[],int n)
{
double ans = 0;
for(int i = 0; i < n; i++)
{
ans += (p[i]^p[(i+1)%n])/2;
}
return fabs(ans);
} double dist(Point a,Point b)
{
return sqrt((a-b)*(a-b));
} Point p[maxn];
Point tp[maxn];
void cut(double a,double b,double c,Point p[],int &cnt)
{
int tmp = 0;
for(int i = 1; i <= cnt; i++)
{
if(a*p[i].x+b*p[i].y+c < eps) tp[++tmp] = p[i];
else
{
//在p[i]处大于0,那么交点可能在(p[i-1],p[i])or(p[i+1],p[i])
if(a*p[i-1].x + b*p[i-1].y + c < -eps)
tp[++tmp] = Intersection(p[i-1],p[i],a,b,c);
if(a*p[i+1].x + b*p[i+1].y + c < -eps)
tp[++tmp] = Intersection(p[i],p[i+1],a,b,c);
}
}
for(int i = 1; i <= tmp; i++)
p[i] = tp[i];
p[0] = p[tmp];
p[tmp+1] = p[1];
cnt = tmp;
}
double inf = 1000000000000000.0;
double U[maxn],V[maxn],W[maxn];
bool cal(int now)
{
p[1] = Point(0,0);
p[2] = Point(0,inf);
p[3] = Point(inf,inf);
p[4] = Point(inf,0);
p[0] = p[4];
p[5] = p[1];
int cnt = 4;
for(int i = 0; i < n; i++)
{
if(i == now) continue;
double a = (U[i]-U[now])/(U[i]*U[now]); //1/U[now] - 1/U[i]
double b = (V[i]-V[now])/(V[i]*V[now]);
double c = (W[i]-W[now])/(W[i]*W[now]);
if(sgn(a)==0 && sgn(b) == 0 )
{
if(sgn(c) >= 0)
return false;
else
continue;
}
cut(a,b,c,p,cnt);
}
if(sgn(CalArea(p,cnt)) == 0)
return false;
else
return true;
} int main()
{
// freopen("in.txt","r",stdin);
while(scanf("%d",&n)!= EOF)
{
for(int i = 0; i < n; i++)
{
scanf("%lf%lf%lf",&U[i],&V[i],&W[i]);
}
for(int i = 0; i < n; i++)
{
if(cal(i))
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}

  

poj 1755 半平面交+不等式的更多相关文章

  1. poj 1279 半平面交核面积

    Art Gallery Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6668   Accepted: 2725 Descr ...

  2. poj 3525 半平面交求多边形内切圆最大半径【半平面交】+【二分】

    <题目链接> 题目大意:给出一个四面环海的凸多边形岛屿,求出这个岛屿中的点到海的最远距离. 解题分析: 仔细思考就会发现,其实题目其实就是让我们求该凸多边形内内切圆的最大半径是多少.但是, ...

  3. POJ 3525 /// 半平面交 模板

    题目大意: 给定n,接下来n行逆时针给定小岛的n个顶点 输出岛内离海最远的点与海的距离 半平面交模板题 将整个小岛视为由许多半平面围成 那么以相同的比例缩小这些半平面 一直到缩小到一个点时 那个点就是 ...

  4. poj 3335 /poj 3130/ poj 1474 半平面交 判断核是否存在 / poj1279 半平面交 求核的面积

    /*************** poj 3335 点序顺时针 ***************/ #include <iostream> #include <cmath> #i ...

  5. POJ 3525 半平面交+二分

    二分所能形成圆的最大距离,然后将每一条边都向内推进这个距离,最后所有边组合在一起判断时候存在内部点 #include <cstdio> #include <cstring> # ...

  6. POJ 3335 Rotating Scoreboard 半平面交求核

    LINK 题意:给出一个多边形,求是否存在核. 思路:比较裸的题,要注意的是求系数和交点时的x和y坐标不要搞混...判断核的顶点数是否大于1就行了 /** @Date : 2017-07-20 19: ...

  7. POJ 1755 Triathlon [半平面交 线性规划]

    Triathlon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6912   Accepted: 1790 Descrip ...

  8. POJ 1755 Triathlon(线性规划の半平面交)

    Description Triathlon is an athletic contest consisting of three consecutive sections that should be ...

  9. POJ 1755 Triathlon (半平面交)

    Triathlon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4733   Accepted: 1166 Descrip ...

随机推荐

  1. 2018上c语言第0次作业

    随笔: 1.翻阅邹欣老师博客关于师生关系博客,并回答下列问题,每个问题的答案不少于500字: (1)最理想的师生关系是健身教练和学员的关系,在这种师生关系中你期望获得来自老师的哪些帮助? 答:对此问题 ...

  2. 团队作业4——第一次项目冲刺(Alpha版本)2017.11.19

    第三次会议:2017-11-16 第二次会议讨论的还没有完全实现,于是在第三次会议上对此进行了一些对我们工作上的看法,得出结论:多花时间啊!!!! 又没照照片图: 会议主要内容: 1.登录注册完善 2 ...

  3. css3 文字的设置

    1.text-shadow 有3个length参数,第1个表示水平偏移,第2个表示垂直偏移,第3个表示模糊(可选) .text11{text-shadow: 3px 3px 5px #f00 ;col ...

  4. Flask 测试

    测试是每个应用系统发布前必须经历的步骤,自动化测试对测试效率的提高也是毋庸置疑的.对于Flask应用来说,当然可以使用Web自动化测试工具,比如Selenium等来测.Flask官方推荐的自动化测试方 ...

  5. nyoj 对决

    对决 时间限制:1000 ms  |  内存限制:65535 KB 难度:0   描述 Topcoder 招进来了 n 个新同学,Yougth计划把这个n个同学分成两组,要求每组中每个人必须跟另一组中 ...

  6. python 之 列表list && 元组tuple

    目录: 列表 列表基本操作 列表的操作符 列表的函数和方法 元组 介绍: 列表是一种可变的有序集合,可以进行访问.添加和删除操作. 元组是一种不可变的有序集合,可以访问. 1.列表的基本操作 创建列表 ...

  7. Python-进程与线程理论基础-Day10

    进程与线程理论基础 1.背景知识 理论基础: 一 操作系统的作用: 1:隐藏丑陋复杂的硬件接口,提供良好的抽象接口 2:管理.调度进程,并且将多个进程对硬件的竞争变得有序 二 多道技术: 1.产生背景 ...

  8. angular2 学习笔记 ( unit test 单元测试 )

    第一次写单元测试. 以前一直都有听说 TDD 的事情. 今天总算是去尝试了一下. 先说说 TDD 的想法, 是这样的, 开发项目的流程 : 确定需求 -> 写类,接口,方法的名字(不写具体实现代 ...

  9. python入门(5)使用文件编辑器编写代码并保存执行

    python入门(5)使用文件编辑器编写代码并保存执行 两款文本编辑器: 一个是Sublime Text,免费使用,但是不付费会弹出提示框: 一个是Notepad++,免费使用,有中文界面: 请注意, ...

  10. C# 文件操作类大全

      C# 文件操作类大全 时间:2015-01-31 16:04:20      阅读:1724      评论:0      收藏:0      [点我收藏+] 标签: 1.创建文件夹 //usin ...