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

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

Source

这题坑了很久,总感觉有问题。

精度开到1e-18才过

 /* ***********************************************
Author :kuangbin
Created Time :2013/8/18 19:47:45
File Name :F:\2013ACM练习\专题学习\计算几何\半平面交\POJ1755_2.cpp
************************************************ */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
const double eps = 1e-;
int sgn(double x)
{
if(fabs(x) < eps)return ;
if(x < )return -;
else return ;
}
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;
}
};
//计算多边形面积
double CalcArea(Point p[],int n)
{
double res = ;
for(int i = ;i < n;i++)
res += (p[i]^p[(i+)%n]);
return fabs(res/);
}
//通过两点,确定直线方程
void Get_equation(Point p1,Point p2,double &a,double &b,double &c)
{
a = p2.y - p1.y;
b = p1.x - p2.x;
c = p2.x*p1.y - p1.x*p2.y;
}
//求交点
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;
}
Point tp[];
void Cut(double a,double b,double c,Point p[],int &cnt)
{
int tmp = ;
for(int i = ;i <= cnt;i++)
{
//当前点在左侧,逆时针的点
if(a*p[i].x + b*p[i].y + c < eps)tp[++tmp] = p[i];
else
{
if(a*p[i-].x + b*p[i-].y + c < -eps)
tp[++tmp] = Intersection(p[i-],p[i],a,b,c);
if(a*p[i+].x + b*p[i+].y + c < -eps)
tp[++tmp] = Intersection(p[i],p[i+],a,b,c);
}
}
for(int i = ;i <= tmp;i++)
p[i] = tp[i];
p[] = p[tmp];
p[tmp+] = p[];
cnt = tmp;
}
double V[],U[],W[];
int n;
const double INF = 100000000000.0;
Point p[];
bool solve(int id)
{
p[] = Point(,);
p[] = Point(INF,);
p[] = Point(INF,INF);
p[] = Point(,INF);
p[] = p[];
p[] = p[];
int cnt = ;
for(int i = ;i < n;i++)
if(i != id)
{
double a = (V[i] - V[id])/(V[i]*V[id]);
double b = (U[i] - U[id])/(U[i]*U[id]);
double c = (W[i] - W[id])/(W[i]*W[id]);
if(sgn(a) == && sgn(b) == )
{
if(sgn(c) >= )return false;
else continue;
}
Cut(a,b,c,p,cnt);
}
if(sgn(CalcArea(p,cnt)) == )return false;
else return true;
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(scanf("%d",&n) == )
{
for(int i = ;i < n;i++)
scanf("%lf%lf%lf",&V[i],&U[i],&W[i]);
for(int i = ;i < n;i++)
{
if(solve(i))printf("Yes\n");
else printf("No\n");
}
}
return ;
}

POJ 1755 Triathlon (半平面交)的更多相关文章

  1. POJ 1755 Triathlon 半平面交

    看的这里:http://blog.csdn.net/non_cease/article/details/7820361 题意:铁人三项比赛,给出n个人进行每一项的速度vi, ui, wi;  对每个人 ...

  2. POJ 3130 How I Mathematician Wonder What You Are! /POJ 3335 Rotating Scoreboard 初涉半平面交

    题意:逆时针给出N个点,求这个多边形是否有核. 思路:半平面交求多边形是否有核.模板题. 定义: 多边形核:多边形的核可以只是一个点,一条直线,但大多数情况下是一个区域(如果是一个区域则必为 ).核内 ...

  3. POJ 3384 Feng Shui 半平面交

    题目大意:一个人很信"Feng Shui",他要在房间里放两个圆形的地毯. 这两个地毯之间可以重叠,可是不能折叠,也不能伸到房间的外面.求这两个地毯可以覆盖的最大范围.并输出这两个 ...

  4. POJ 1755 Triathlon

    http://poj.org/problem?id=1755 题意:铁人三项,每个人有自己在每一段的速度,求有没有一种3条路线长度都不为0的设计使得某个人能严格获胜? 我们枚举每个人获胜,得到不等式组 ...

  5. 【kuangbin专题】计算几何_半平面交

    1.poj3335 Rotating Scoreboard 传送:http://poj.org/problem?id=3335 题意:就是有个球场,球场的形状是个凸多边形,然后观众是坐在多边形的边上的 ...

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

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

  7. 【BZOJ-4515】游戏 李超线段树 + 树链剖分 + 半平面交

    4515: [Sdoi2016]游戏 Time Limit: 40 Sec  Memory Limit: 256 MBSubmit: 304  Solved: 129[Submit][Status][ ...

  8. poj3335 半平面交

    题意:给出一多边形.判断多边形是否存在一点,使得多边形边界上的所有点都能看见该点. sol:在纸上随手画画就可以找出规律:按逆时针顺序连接所有点.然后找出这些line的半平面交. 题中给出的点已经按顺 ...

  9. POJ3525 半平面交

    题意:求某凸多边形内部离边界最远的点到边界的距离 首先介绍半平面.半平面交的概念: 半平面:对于一条有向直线,它的方向的左手侧就是它所划定的半平面范围.如图所示: 半平面交:多个半平面的交集.有点类似 ...

  10. bzoj2618[Cqoi2006]凸多边形 半平面交

    这是一道半平面交的裸题,第一次写半平面交,就说一说我对半平面交的理解吧. 所谓半平面交,就是求一大堆二元一次不等式的交集,而每个二元一次不等式的解集都可以看成是在一条直线的上方或下方,联系直线的标准方 ...

随机推荐

  1. UOJ#58/BZOJ 3052【WC2013】糖果公园

    好写好调的莫队算法,就算上树了仍然好写好调. 传送门 http://uoj.ac/problem/58 简要做法 将树按照dfs序分块,然后将询问按照(u所在块,v所在块,时间)作为关键字进行排序,依 ...

  2. 005zabbix3.0报错记录

    一.问题描述 在zabbix_server添加变量时,出现了以下的报错,

  3. 大型网站的 HTTPS 实践(一)—— HTTPS 协议和原理(转)

    原文链接:http://op.baidu.com/2015/04/https-s01a01/ 1 前言 百度已经于近日上线了全站 HTTPS 的安全搜索,默认会将 HTTP 请求跳转成 HTTPS.本 ...

  4. Codeforces 776C - Molly's Chemicals(思维+前缀和)

    题目大意:给出n个数(a1.....an),和一个数k,问有多少个区间的和等于k的幂 (1 ≤ n ≤ 10^5, 1 ≤ |k| ≤ 10, - 10^9 ≤ ai ≤ 10^9) 解题思路:首先, ...

  5. django的orm中F对象的使用

    今天不巧就用上了. 就是将数据库的字段,自增1的场景. from django.db.models import F DeployPool.objects.filter(name=deployvers ...

  6. JavaScript“并非”一切皆对象

    上一篇:<函数声明和函数表达式--函数声明和函数表达式的异同> p{font-size:14px; } 写在前面 网上非常多都在说"JavaScript一切皆对象",那 ...

  7. DotNetOpenAuth实践之Webform资源服务器配置

    系列目录: DotNetOpenAuth实践系列(源码在这里) 上篇我们讲到WebApi资源服务器配置,这篇我们说一下Webform下的ashx,aspx做的接口如何使用OAuth2认证 一.环境搭建 ...

  8. [实战]MVC5+EF6+MySql企业网盘实战(5)——登录界面,头像等比例压缩

    写在前面 关于该项目,已经很久没更新了.实在是找不到一个好的ui,没办法就在网上找了一个还不错的,就凑合着先用着吧,先出第一版,以后的再想着去优化.最近更新与网盘项目相关的内容是准备在项目中使用一个美 ...

  9. vim编码相关

    与vim编码相关的四个配置: encoding:vim核心编码,所有vim交换区,信息提示区都用这个编码.打开文件的编码如果是其他编码,会自动转换为核心编码,保存时再转回文件编码. fileencod ...

  10. ref:学习笔记 UpdateXml() MYSQL显错注入

    ref:https://www.cnblogs.com/MiWhite/p/6228491.html 学习笔记 UpdateXml() MYSQL显错注入 在学习之前,需要先了解 UpdateXml( ...