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

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


题意:

3800: Saber VS Lancer

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 69  Solved: 25
[Submit][Status][Discuss]

Description

铁人三项是一种运动项目,和字面意思一样,是让铁做的人(?)去做三个项目,必须连续完成,而且全程讲求速度。第一项是游泳,第二项是骑自行车,第三项是跑步。现在所有选手的三个项目的速度都是已知的。但是这次比赛中,裁判可以任意选择每一个项目的路程长度(假设没有一项长度为0)。但是这样显然会影响比赛排名……有时她会按某种方式选择,使得一些个别的选手能赢得竞赛。

Input

首行为运动员的人数N (1 ≤ N ≤ 100,80%的数据中n<=20),以下N行,每行含3个整数,Vi, Ui 和Wi (1 ≤ Vi, Ui, Wi ≤ 10000),用空格隔开,表示各人3个项目的速度。 

Output

对于每个运动员,都用一行输出,假如裁判以某种方式选择的路程会使得他赢(即第一个冲线,同时抵达不算赢),则输出“Yes”,否则输出“No”  。

卡精度太恶心了...........................两个小时!!!
对着 http://blog.csdn.net/acm_cxlove/article/details/7883370 调了好久终于用自己的写法A掉了
设长度x,y,1 两人列不等式  得到ax+by+c>0然后用半平面交模拟高中线性规划的做法......
 
直线方程和向量配合起来用太神了,注意那个直线和直线方程求交点的方法abcLI
 
注意:
Yes和No不是全大写
if(sgn(f(C))!=sgn(f(D))&&sgn(f(C))!=0&&sgn(f(D))!=0) 因为交点在直线上是不行的 我也不知道为什么要这样瞎凑出来的
 
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
const int N=;
const double INF=1e9;
const double eps=1e-1;
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-; c=getchar();}
while(c>=''&&c<=''){x=x*+c-''; c=getchar();}
return x*f;
} inline int sgn(double x){
if(abs(x)<eps) return ;
else return x<?-:;
} struct Vector{
double x,y;
Vector(double a=,double b=):x(a),y(b){}
bool operator <(const Vector &a)const{
return sgn(x-a.x)<||(sgn(x-a.x)==&&sgn(y-a.y)<);
}
void print(){printf("%lf %lf\n",x,y);}
};
typedef Vector Point;
Vector operator +(Vector a,Vector b){return Vector(a.x+b.x,a.y+b.y);}
Vector operator -(Vector a,Vector b){return Vector(a.x-b.x,a.y-b.y);}
Vector operator *(Vector a,double b){return Vector(a.x*b,a.y*b);}
Vector operator /(Vector a,double b){return Vector(a.x/b,a.y/b);}
bool operator ==(Vector a,Vector b){return sgn(a.x-b.x)==&&sgn(a.y-b.y)==;}
double Dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
double Cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
double Len(Vector a){return sqrt(Dot(a,a));}
Vector Normal(Vector a){
return Vector(-a.y,a.x);//counterClockwise
};
struct Line{
Point s,t;
Line(){}
Line(Point a,Point b):s(a),t(b){}
};
bool isLSI(Line l1,Line l2){
Vector v=l1.t-l1.s,u=l2.s-l1.s,w=l2.t-l1.s;
return sgn(Cross(v,u))!=sgn(Cross(v,w));
}
Point LI(Line a,Line b){
Vector v=a.s-b.s,v1=a.t-a.s,v2=b.t-b.s;
double t=Cross(v2,v)/Cross(v1,v2);
return a.s+v1*t;
} void iniPolygon(Point p[],int &n,double inf){
n=;
p[++n]=Point(,);
p[++n]=Point(,inf);
p[++n]=Point(inf,inf);
p[++n]=Point(inf,);
}
Point t[N];int tn;
double a,b,c;
double f(Point p){return a*p.x+b*p.y+c;}
Point abcLI(Line l){
double u=abs(f(l.s)),v=abs(f(l.t));
return Point(l.s.x*v+l.t.x*u,l.s.y*v+l.t.y*u)/(u+v);
}
void CutPolygon(Point p[],int &n){
tn=;
Point C,D;
p[]=p[n];p[n+]=p[];
for(int i=;i<=n;i++){
C=p[i],D=p[i%n+];
if(sgn(f(C))>=) t[++tn]=C;
if(sgn(f(C))!=sgn(f(D))&&sgn(f(C))!=&&sgn(f(D))!=) t[++tn]=abcLI(Line(C,D));
//else{
// if(sgn(f(p[i-1]))>0) t[++tn]=abcLI(Line(p[i-1],p[i]));
// if(sgn(f(p[i+1]))>0) t[++tn]=abcLI(Line(p[i],p[i+1]));
//}
}
n=tn;for(int i=;i<=n;i++) p[i]=t[i];
} double PolygonArea(Point p[],int n){
double s=;
for(int i=;i<n;i++) s+=Cross(p[i]-p[],p[i+]-p[]);
return abs(s/);
}
struct Saber{
double a,b,c;
}s[N];
int n,m;
Point q[N];
bool solve(int id){
iniPolygon(q,m,INF);
q[]=q[];q[]=q[];
for(int i=;i<=n;i++) if(i!=id){
a=(s[id].a-s[i].a)/(s[id].a*s[i].a);//ax+by+c>0
b=(s[id].b-s[i].b)/(s[id].b*s[i].b);
c=(s[id].c-s[i].c)/(s[id].c*s[i].c);
if(sgn(a)==&&sgn(b)==&&sgn(c)<=) return false;
CutPolygon(q,m);
}
return sgn(PolygonArea(q,m));
} int main(int argc, const char * argv[]){
n=read();
for(int i=;i<=n;i++) s[i].a=read(),s[i].b=read(),s[i].c=read();
for(int i=;i<=n;i++) puts(solve(i)?"Yes":"No");
}
 
 

POJ 1755 Triathlon [半平面交 线性规划]的更多相关文章

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

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

  2. POJ 1755 Triathlon (半平面交)

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

  3. POJ 1755 Triathlon

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

  4. poj 3335(半平面交)

    链接:http://poj.org/problem?id=3335     //大牛们常说的测模板题 ------------------------------------------------- ...

  5. LA 2218 Triathlon(半平面交)

    Triathlon [题目链接]Triathlon [题目类型]半平面交 &题解: 做了2道了,感觉好像套路,都是二分答案,判断半平面交是否为空. 还有刘汝佳的代码总是写const +& ...

  6. POJ 1755 Triathlon 半平面交

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

  7. LA2218 Triathlon /// 半平面交 oj22648

    题目大意: 铁人三项分连续三段:游泳 自行车 赛跑 已知各选手在每个单项中的速度v[i],u[i],w[i] 设计每个单项的长度 可以让某个特定的选手获胜 判断哪些选手有可能获得冠军 输出n行 有可能 ...

  8. poj 1755 半平面交+不等式

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

  9. poj 1279 半平面交核面积

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

随机推荐

  1. Android studio启动后卡在refreshing gradle project(包解决)

    这个问题几乎每个刚使用Android studio的同学都会碰到过,网上有各式各样的方法,有的说使用本地gradle,我试过多次,每次启动android studio时还是会检查更新,所以根本上解决的 ...

  2. ThinkPHP配置文件的加载

    分类: thinkphp(39) 版权声明:本文为博主原创文章,未经博主允许不得转载. 惯例配置->应用配置->模式配置->调试配置->状态配置->模块配置->扩展 ...

  3. ThinkPhp 添加模型类

    ----------------------------------------------- <?phpnamespace app\common\model;use traits\model\ ...

  4. 邓_phpcms_数据库

    phpcms v9 数据表结构 在线版 PHPCMS V9 数据结构 (2010-12-28) 表 1 : v9_admin 管理员表 字段 类型 Null 默认 额外 注释 userid mediu ...

  5. [SinGuLaRiTy] 复习模板-搜索

    [SinGuLaRiTy-1043] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. 桶排序 void bucketSort(int a[], ...

  6. 使用SQLQuery 在Hibernate中使用sql语句

    对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行Session.createSQLQuery()获取这个接口.下面来描述如何使用这个API进行查询. 1.标量查询(Scalar q ...

  7. (Release Candidate)Candidate

    RC:(Release Candidate)Candidate是候选人的意思,用在软件或者操作系统上就是候选版本

  8. mysql索引使用注意事项

    索引是快速搜索的关键.MySQL索引的建立对于MySQL的高效运行是很重要的.下面介绍几种常见的MySQL索引类型. 在数据库表中,对字段建立索引可以大大提高查询速度.假如我们创建了一个 mytabl ...

  9. salesforce零基础学习(八十一)更改标准字段的label名称(Admin)

    我们在开发中往往需要考虑国际化功能,salesforce 提供了国际化功能,在search部分搜索translate,便可以找到translate部分,从而对需要的进行translate.比如pick ...

  10. fread读取文件(二进制文件)

    fread()是c库函数,利于移植,使用缓存,效率较read()高. 原型: size_t fread(void *buffer, size_t size, size_t count, FILE * ...