###### poj 1755 Triathlon （半平面交求解不等式组）

Triathlon
 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6881 Accepted: 1780

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

[Submit]   [Go Back]   [Status]   [Discuss]

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define N 103
#define eps 1e-16
#define inf 1000000000
using namespace std;
struct vector {
double x,y;
vector (double X=0,double Y=0){
x=X,y=Y;
}
}a1[N],p[N],tmp[N];
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 t)
{
return vector (a.x*t,a.y*t);
}
vector operator !=(vector a,vector b){
return a.x!=b.x||a.y!=b.y;
}
struct data{
point a,b;
}line[N];
double a[N],b[N],c[N];
int n,m;
void init()
{
m=0;
p[m++]=point(inf,inf);
p[m++]=point(eps,inf);
p[m++]=point(eps,eps);
p[m++]=point(inf,eps);
}
int dcmp(double x)
{
if (fabs(x)<eps) return 0;
return x<0?-1:1;
}
double cross(vector a,vector b)
{
return a.x*b.y-a.y*b.x;
}
point glt(point a,point a0,point b,point b0)
{
double a1,b1,c1,a2,b2,c2;
a1 = a.y - a0.y;
b1 = a0.x - a.x;
c1 = cross(a,a0);
a2 = b.y - b0.y;
b2 = b0.x - b.x;
c2 = cross(b,b0);
double d = a1 * b2 - a2 * b1;
return point((b1 * c2 - b2 * c1) / d,(c1 * a2 - c2 * a1) / d);
}
void cut(point a,point b)
{
int cnt=0;
memset(tmp,0,sizeof(tmp));
for (int i=0;i<m;i++){
double c=cross(b-a,p[i]-a);
double d=cross(b-a,p[(i+1)%m]-a);
if (dcmp(c)>=0)
tmp[cnt++]=p[i];
if (dcmp(c)*dcmp(d)<0)
tmp[cnt++]=glt(a,b,p[i],p[(i+1)%m]);
}
m=0;
for (int i=0;i<cnt;i++)
if (m==0 || (tmp[i].x!=p[m-1].x||tmp[i].y!=p[m-1].y))
p[m++]=tmp[i];
}
int main()
{
freopen("a.in","r",stdin);
freopen("my.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%lf%lf%lf",&a[i],&b[i],&c[i]);
for (int i=1;i<=n;i++){
int k=0;
bool mark=true;
for (int j=1;j<=n;j++){
if (i==j) continue;
double nowa=1.0/a[j]-1.0/a[i];
double nowb=1.0/b[j]-1.0/b[i];
double nowc=1.0/c[j]-1.0/c[i];
if (dcmp(nowa)==0&&dcmp(nowb)==0) {
if (dcmp(nowc)>0) continue;
else {
mark=false;
break;
}
}
k++;
if (dcmp(nowb)==0) {
double t=-nowc/nowa;
line[k].a.x=t; line[k].b.x=t;
line[k].a.y=1; line[k].b.y=2;
if (dcmp(nowa)>0) swap(line[k].a,line[k].b);
continue;
}
line[k].a.x=1;
line[k].a.y=-(nowa+nowc)/nowb;
line[k].b.x=2;
line[k].b.y=-(nowa*2.0+nowc)/nowb;
if (dcmp(nowb)<0) swap(line[k].a,line[k].b);
}
if (!mark){
printf("No\n");
continue;
}
init();
for (int  j=1;j<=k;j++)
cut(line[j].a,line[j].b);
double area=0; p[m]=p[0];
for (int j=1;j<m;j++) area+=cross(p[j]-p[0],p[j+1]-p[0]);
area=fabs(area);
if (m>2&&dcmp(area)>0) printf("Yes\n");
else printf("No\n");
}
}

#### poj1755 半平面交解不等式组

2012-08-01 22:50:01

#### poj1755Triathlon【半平面交】

2015-09-20 01:22:05

#### POJ 1755 Triathlon（半平面交解不等式）

2012-08-19 15:49:12

#### 【半平面交】 POJ 1755 Triathlon

2014-08-21 20:41:13

#### poj 1755 Triathlon 半平面交

2016-08-24 14:00:21

#### POJ 1755 Triathlon 半平面交

2013-08-29 10:35:24

#### POJ 1755 Triathlon【半平面交】

2012-08-22 00:01:17

#### poj 1755 Triathlon（半平面交解不等式）

2013-09-03 19:21:19

#### poj 1755 Triathlon(半平面交应用)

2012-09-06 21:07:38

#### poj 1755 （半平面交解不等式）

2017-04-15 20:23:51

## 不良信息举报

poj 1755 Triathlon （半平面交求解不等式组）