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. C#技术分享【PDF转换成图片——11种方案】

    1.[iTextSharp.dll],C# 开源PDF处理工具,可以任意操作PDF,并可以提取PDF中的文字和图片,但不能直接将PDF转换成图片. DLL和源码 下载地址:http://downloa ...

  2. gan对抗式网络

    感觉好厉害,由上图噪声,生成左图噪声生成右图以假乱真的图片, gan网络原理: 本弱又盗了一坨博文,不是我写的,如下:(跪膜各路大神) 前面我们已经讲完了一般的深层网络,适用于图像的卷积神经网络,适用 ...

  3. Java显式锁学习总结之四:ReentrantLock源码分析

    概述 ReentrantLock,即重入锁,是一个和synchronized关键字等价的,支持线程重入的互斥锁.只是在synchronized已有功能基础上添加了一些扩展功能. 除了支持可中断获取锁. ...

  4. [Ext JS 4]后台自动产生图档

    前言 [Ext JS 4] 实战之将chart导出为png, jpg 格式的文件 承接上一篇, 我们可以做到在Browser端打开一个Chart,并导出为png或是jpg 等格式的图档. 但实际的需求 ...

  5. 使用jdk自带的工具native2ascii 转换Unicode字符和汉字

    1.控制台转换 1.1 将汉字转为Unicode: C:\Program Files\Java\jdk1.5.0_04\bin>native2ascii 测试 \u6d4b\u8bd5 1.2 ...

  6. java 基础知识-数组的7种算法(排序、求和、最值、遍历...)

    遍历 遍历就是把这个数组的每个元素 显示出来 遍历的方法就是先定义这个数组的大小,然后用FOR循环来完成数组,例如 double[] score = new double[5]; Scanner in ...

  7. 第 18 章 Django 入门

    当今的网站实际上都是富应用程序(rich application),就像成熟的桌面应用程序一样.Python提供了一组开发Web应用程序的卓越工具.在本章中,我们将学习如何使用Django(http: ...

  8. SQLyog-12.0.9-0.x64

    SQLyog-12.0.9-0.x64 下载地址 链接:https://pan.baidu.com/s/1AjC2rdx8Bgtns1sYmN5NEw 提取码:icko 注册码: 姓名(Name):c ...

  9. .NET基本权限系统框架源代码

    DEMO下载地址: 百度网盘:http://pan.baidu.com/s/147ilj http://download.csdn.net/detail/shecixiong/5372895 一.开发 ...

  10. SpringBoot入门系列

    集合redis,mysql,测试例子 http://blog.csdn.net/lxhjh/article/details/51764604