poj 1755 Triathlon(半平面交解可行域)
来源:互联网 发布:文件上传阿里云oss2 编辑:程序博客网 时间:2024/05/22 04:23
Triathlon
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4990 Accepted: 1251
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.
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
910 2 610 7 35 6 73 2 76 2 63 5 78 4 610 4 21 8 7
Sample Output
YesYesYesNoNoNoYesNoYes
Source
Northeastern Europe 2000
题意:举行一项铁人三项运动,给出每个人在每个项目的速度,问对于每一个人,是否可以设计一定长度的跑道,使某个人获胜
题解:将3个未知数根据约束关系化成2个,详细题解的话推荐以下博客,已经很详细了,就不再写了
另外要注意的是,这题精度真的很难控制。。。RP不好就会WA了,eps在1e-16比较保险。。。和别人代码差不多,但是还是不断死在精度上面,真不懂为什么别人1e-8能A,我要1e-16才能A,哎。。。
点击打开链接
或 点击打开链接
#include<stdio.h>#include<math.h>#define eps 1e-8#define N 108#define inf 0xffffffstruct point{ double x,y;}p[1508],temp[1508],tp[1508];double a[N],b[N],c[N];double a1,b1,c1;int all;double cross(struct point p1,struct point p2,struct point p3){ return (p2.x-p1.x)*(p3.y-p1.y)-(p2.y-p1.y)*(p3.x-p1.x);}void init(){ int i; all=4; p[1].x=0; p[1].y=0; p[2].x=0; p[2].y=inf; p[3].x=inf; p[3].y=inf; p[4].x=inf; p[4].y=0; p[0]=p[4],p[5]=p[1]; for(i=0;i<=all+1;i++) temp[i]=p[i];}void get_line(int x,int y){ a1=(a[y]-a[x])/(a[x]*a[y]); b1=(b[y]-b[x])/(b[x]*b[y]); c1=(c[y]-c[x])/(c[x]*c[y]);}void get_intersect(struct point p1,struct point p2){ double a2=p1.y-p2.y; double b2=p2.x-p1.x; double c2=p1.x*p2.y-p2.x*p1.y; double tmd=a1*b2-a2*b1; temp[1506].x=(b1*c2-b2*c1)/tmd; temp[1506].y=(a2*c1-a1*c2)/tmd;}void cut(){ int top=0,i; for(i=1;i<=all;i++) { if(a1*temp[i].x+b1*temp[i].y+c1<eps) tp[++top]=temp[i]; else { if(a1*temp[i-1].x+b1*temp[i-1].y+c1<-eps) { get_intersect(temp[i-1],temp[i]); tp[++top]=temp[1506]; } if(a1*temp[i+1].x+b1*temp[i+1].y+c1<-eps) { get_intersect(temp[i+1],temp[i]); tp[++top]=temp[1506]; } } } all=top; tp[0]=tp[all],tp[all+1]=tp[1]; for(i=0;i<=all+1;i++) temp[i]=tp[i];}int main(){ int n,i,j,flag; double area; //freopen("t.txt","r",stdin); while(scanf("%d",&n)>0) { for(i=0;i<n;i++) scanf("%lf%lf%lf",&a[i],&b[i],&c[i]); for(i=0;i<n;i++) { init(); for(flag=1,j=0;j<n&&flag;j++) { if(i==j) continue; get_line(i,j); if(a1==0&&b1==0&&c1>-eps) flag=0; cut(); } for(area=0,j=2;j<all;j++) area+=cross(temp[1],temp[j],temp[j+1]); if(fabs(area/2.0)<1e-16||!flag) printf("No\n"); else printf("Yes\n"); } } return 0;}
0 0
- poj 1755 Triathlon(半平面交解可行域)
- Poj 1755 Triathlon (半平面交求可行域)
- POJ 1755 Triathlon(半平面交解不等式)
- poj 1755 Triathlon(半平面交解不等式)
- POJ 1755 Triathlon 半平面交
- POJ 1755 Triathlon【半平面交】
- poj 1755 Triathlon(半平面交应用)
- POJ 1755 Triathlon 半平面交
- POJ 1755 Triathlon 半平面交
- 【半平面交】 POJ 1755 Triathlon
- poj 1755 Triathlon 半平面交
- poj 1755 Triathlon (半平面交求解不等式组)
- POJ 1755-Triathlon(半平面交-铁人三项)
- POJ 1755 Triathlon (计算几何+半平面交解决线性规划)
- POJ 1755 Triathlon 判断不等式有解+半平面的交
- poj 1755 Triathlon(半平面解线性规划)
- URAL 1062 - Triathlon(半平面交)
- poj1755 Triathlon 半平面交
- lint优化项
- arcgis 10.2 中 制作离线包 tpk
- Lua Table to Json
- rails view层的具体细节(四)
- java泛型的解释
- poj 1755 Triathlon(半平面交解可行域)
- C++经典面试题库 附带参考答案
- 数据库初始化脚本
- 360°平滑游戏摇杆(触屏方向导航)
- DAL、DAO、ORM、Active Record辨析
- CMake+MinGW编译OpenCV-2.4.7
- 【python PIL学习】给照片打水印
- sed命令详解
- 用Ant实现Java项目的自动构建和部署