https://vjudge.net/problem/UVALive-2218

题意:

铁人三项比赛,每项比赛长度未定,已知每个选手每项比赛的平均速度。

设计每项比赛的长度,让其中某个特定选手获胜。

判断哪些选手有可能 获得冠军,并列不算

每项比赛长度必须>0

线性规划问题

设比赛总长度为1,第一项长度为x,第二项长度为y,第三项长度为1-x-y

则选手i打败选手j的条件是

化为Ax+By+C>0,得

对于每个选手i,都会得到n-1个半平面

再加上x>0,y>0,1-x-y>0

一共n+2个半平面

如果这n+2个半平面有交,那么选手i可能获得冠军

#include<cmath>
#include<cstdio>
#include<algorithm> #define N 104 using namespace std; const double eps=1e-; struct Point
{
double x,y; Point(double x=,double y=) : x(x),y(y) { } }; typedef Point Vector; 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); } struct Line
{
Point P;
Vector v;
double ang; Line() {}
Line(Point P,Vector v) :P(P),v(v) { ang=atan2(v.y,v.x); } bool operator < (Line L) const
{
return ang<L.ang;
}
}; Line L[N]; double Cross(Vector A,Vector B)
{
return A.x*B.y-A.y*B.x;
} bool OnLeft(Line L,Point p)
{
return Cross(L.v,p-L.P)>;
} Point GetIntersection(Line a,Line b)
{
Vector u=a.P-b.P;
double t=Cross(b.v,u)/Cross(a.v,b.v);
return a.P+a.v*t;
} bool HalfplaneIntersection(Line *L,int n)
{
sort(L,L+n);
int first,last;
Point *p=new Point[n];
Line *q=new Line[n];
q[first=last=]=L[];
for(int i=;i<n;++i)
{
while(first<last && !OnLeft(L[i],p[last-])) last--;
while(first<last && !OnLeft(L[i],p[first])) first++;
q[++last]=L[i];
if(fabs(Cross(q[last].v,q[last-].v))<eps)
{
last--;
if(OnLeft(q[last],L[i].P)) q[last]=L[i];
}
if(first<last) p[last-]=GetIntersection(q[last-],q[last]);
}
while(first<last && !OnLeft(q[first],p[last-])) last--;
return last-first>;
} int V[N],U[N],W[N]; int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<n;++i) scanf("%d%d%d",&V[i],&U[i],&W[i]);
for(int i=;i<n;++i)
{
int lc=; bool ok=true;
double k=;
for(int j=;j<n;++j)
if(i!=j)
{
if(V[i]<=V[j] && U[i]<=U[j] && W[i]<=W[j]) { ok=false; break; }
if(V[i]>=V[j] && U[i]>=U[j] && W[i]>=W[j]) continue;
double a=(k/V[j]-k/W[j])-(k/V[i]-k/W[i]);
double b=(k/U[j]-k/W[j])-(k/U[i]-k/W[i]);
double c=k/W[j]-k/W[i];
Point P;
Vector v(b,-a);
if(fabs(a)>fabs(b)) P=Point(-c/a,);
else P=Point(,-c/b);
L[lc++]=Line(P,v);
}
if(ok)
{
L[lc++]=Line(Point(,),Vector(,-));
L[lc++]=Line(Point(,),Vector(,));
L[lc++]=Line(Point(,),Vector(-,));
if(!HalfplaneIntersection(L,lc)) ok=false;
}
puts(ok ? "Yes" : "No");
}
}
}

UVALive 2218 Triathlon的更多相关文章

  1. LA 2218 Triathlon(半平面交)

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

  2. uva 2218 Triathlon

    题意:铁人三项赛,给定每个选手游泳,自行车,赛跑三个阶段的平均速度,不知道每段比赛的路程,询问当前这个选手能否胜利. 思路:把题意转化为一个不等式,设比赛长度是1,如果i要战胜j,x.y分别是第一阶段 ...

  3. LA 2218 (半平面交) Triathlon

    题意: 有n个选手,铁人三项有连续的三段,对于每段场地选手i分别以vi, ui 和 wi匀速通过. 对于每个选手,问能否通过调整每种赛道的长度使得他成为冠军(不能并列). 分析: 粗一看,这不像一道计 ...

  4. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  5. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  6. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

  7. 思维 UVALive 3708 Graveyard

    题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...

  8. UVALive 6145 Version Controlled IDE(可持久化treap、rope)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  9. UVALive 6508 Permutation Graphs

    Permutation Graphs Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit ...

随机推荐

  1. spring boot 实现文件下载

    html 代码 js部分 window.location.href= this.Baseurl+'/plan/down?file='+filename; spring boot 后台代码@GetMap ...

  2. Error:Could not find common.jar (android.arch.core:common:1.0.0)

    Error:Could not find common.jar (android.arch.core:common:1.0.0). Searched in the following location ...

  3. OD之绕过序列号验证(二)

    上次是修改程序的标题,大家应该感觉这只是一个起点而已,接下来我们可以尝试绕过序列号验证,这种技术应用在很多软件中,比如淘宝上要买什么的软件,商家都会发给`你一个用户名和密码,而且还有试用期什么的,这确 ...

  4. Apache Ignite 学习笔记(二): Ignite Java Thin Client

    前一篇文章,我们介绍了如何安装部署Ignite集群,并且尝试了用REST和SQL客户端连接集群进行了缓存和数据库的操作.现在我们就来写点代码,用Ignite的Java thin client来连接集群 ...

  5. 在windows10上搭建caffe

    caffe环境的搭建一直是让我最头疼的,最近在Windows10上成功搭建了caffe,在此对搭建过程进行记录. 安装主要是按照caffe github上的安装说明进行的,caffe的github主页 ...

  6. POW的重力之美

    定律一:每一个UTXO都保持其状不变,直到有外力迫使它改变这种状态为止--艾萨克•牛顿,原理2.0 在过去的几年里,关于比特币的工作量证明(PoW)所造成的"巨大的能源浪费"已经被 ...

  7. 第四次WBS

    分解原则 1.将主体目标逐步细化分解,最底层的日常活动可直接分派到个人去完成: 2.每个任务原则上要求分解到不能再细分为止: 3.日常活动要对应到人.时间和资金投入. 二.任务分解的方法 1.采用树状 ...

  8. 安全相关论文--Security and Dependability

    安全相关论文--Security and Dependability 所参考的文献来自于Kreutz D, Ramos F M V, Esteves Verissimo P, et al. Softw ...

  9. spring动态数据源+事务

    今天在尝试配置spring的动态数据源和事务管理的时候,遇到了几处配置上的问题,在此记录下: 1.使用了spring的aop思想,实现了动态数据源的切换. 2.spring的事务管理,是基于数据源的, ...

  10. [转帖]2019 简易Web开发指南

    2019 简易Web开发指南     2019年即将到来,各位同学2018年辛苦了. 不管大家2018年过的怎么样,2019年还是要继续加油的! 在此我整理了个人认为在2019仍是或者将成为主流的技术 ...