题意

PDF

分析

设出长度\(x,y,1-x-y\),就是关于它们的二元一次不等式,判断有没有解。

可以用半平面交来解决。

x/V[i]+y/U[i]+(1-x-y)/W[i] < x/V[j]+y/U[j]+(1-x-y)/W[j]
ax+by+c>0

然后关于这些不等式似乎只能先化为我所熟悉的\(y=kx+b\)然后再做?我没有想出更好的解决方法。

枚举每一个点再枚举点集,时间复杂度\(O(T n^2 \log n)\)

代码

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<ctime>
#include<cstring>
#define rg register
#define il inline
#define co const
template<class T>il T read()
{
    rg T data=0;
    rg int w=1;
    rg char ch=getchar();
    while(!isdigit(ch))
    {
        if(ch=='-')
            w=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        data=data*10+ch-'0';
        ch=getchar();
    }
    return data*w;
}
template<class T>T read(T&x)
{
    return x=read<T>();
}
using namespace std;
typedef long long ll;

struct Point
{
    double x,y;

    Point(double x=0,double y=0)
    :x(x),y(y){}
};
typedef Point Vector;

Vector operator+(co Vector&A,co Vector&B)
{
    return Vector(A.x+B.x,A.y+B.y);
}

Vector operator-(co Vector&A,co Vector&B)
{
    return Vector(A.x-B.x,A.y-B.y);
}

Vector operator*(co Vector&A,double p)
{
    return Vector(A.x*p,A.y*p);
}

double Dot(co Vector&A,co Vector&B)
{
    return A.x*B.x+A.y*B.y;
}

double Cross(co Vector&A,co Vector&B)
{
    return A.x*B.y-A.y*B.x;
}

double Length(co Vector&A)
{
    return sqrt(Dot(A,A));
}

Vector Normal(co Vector&A)
{
    double L=Length(A);
    return Vector(-A.y/L,A.x/L);
}

double PolygonArea(vector<Point>p)
{
    int n=p.size();
    double area=0;
    for(int i=1;i<n-1;++i)
        area+=Cross(p[i]-p[0],p[i+1]-p[0]);
    return area/2;
}

struct Line
{
    Point P;
    Vector v;

    Line(Point P=0,Vector v=0)
    :P(P),v(v){}

    double angle()co
    {
        return atan2(v.y,v.x);
    }

    bool operator<(co Line&rhs)co
    {
        return angle()<rhs.angle();
    }
};

bool OnLeft(co Line&L,co Point&p)
{
    return Cross(L.v,p-L.P)>0;
}

Point LineLineIntersection(co Line&a,co 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;
}

co double eps=1e-6;

vector<Point>HalfplaneIntersection(vector<Line>L)
{
    int n=L.size();
    sort(L.begin(),L.end());

    int first,last;
    vector<Point>p(n);
    vector<Line>q(n);
    vector<Point>ans;

    q[first=last=0]=L[0];
    for(int i=1;i<n;++i)
    {
        while(first<last&&!OnLeft(L[i],p[last-1]))
            --last;
        while(first<last&&!OnLeft(L[i],p[first]))
            ++first;
        q[++last]=L[i];
        if(fabs(Cross(q[last].v,q[last-1].v))<eps)
        {
            --last;
            if(OnLeft(q[last],L[i].P))
                q[last]=L[i];
        }
        if(first<last)
            p[last-1]=LineLineIntersection(q[last-1],q[last]);
    }
    while(first<last&&!OnLeft(q[first],p[last-1]))
        --last;
    if(last-first<=1)
        return ans;
    p[last]=LineLineIntersection(q[last],q[first]);

    for(int i=first;i<=last;++i)
        ans.push_back(p[i]);
    return ans;
}

co int N=100;
int V[N],U[N],W[N];

int main()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;++i)
        {
            read(V[i]);read(U[i]);read(W[i]);
        }
        for(int i=0;i<n;++i)
        {
            bool ok=1;
            double k=1e4;
            vector<Line>L;
            for(int j=0;j<n;++j)
                if(i!=j)
                {
                    if(V[i]<=V[j]&&U[i]<=U[j]&&W[i]<=W[j])
                    {
                        ok=0;
                        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,0);
                    else
                        P=Point(0,-c/b);
                    L.push_back(Line(P,v));
                }
            if(ok)
            {
                L.push_back(Line(Point(0,0),Vector(0,-1)));
                L.push_back(Line(Point(0,0),Vector(1,0)));
                L.push_back(Line(Point(0,1),Vector(-1,1)));
                vector<Point>poly=HalfplaneIntersection(L);
                if(poly.empty())
                    ok=0;
            }
            puts(ok?"Yes":"No");
        }
    }
    return 0;
}

LA2218 Triathlon的更多相关文章

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

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

  2. 铁人系列(2)LA2218

    思路:对于每个人  都会有n-1个半片面  加上x>0,y>0,1-x-y>0(这里的1抽象为总长) 代码是粘贴的  原来写的不见了  orz............ // LA22 ...

  3. POJ 1755 Triathlon [半平面交 线性规划]

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

  4. LA 2218 Triathlon(半平面交)

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

  5. POJ 1755 Triathlon (半平面交)

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

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

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

  7. LA 2218 (半平面交) Triathlon

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

  8. uva 2218 Triathlon

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

  9. uva 1298 - Triathlon

    半平面交的题: 这个题目的亮点就是建模: #include<cstdio> #include<algorithm> #include<cmath> #define ...

随机推荐

  1. PHP-FPM 设置多pool、配置文件重写

    重写配置文件 1.清空php配置文件 命令:> /usr/local/php/etc/php-fpm.conf 2.重新写入php-fpm配置 命令:vim /usr/local/php/etc ...

  2. 近千节点的Redis Cluster高可用集群案例:优酷蓝鲸优化实战(摘自高可用架构)

    (原创)2016-07-26 吴建超 高可用架构导读:Redis Cluster 作者建议的最大集群规模 1,000 节点,目前优酷在蓝鲸项目中管理了超过 700 台节点,积累了 Redis Clus ...

  3. 一个线程知识点, 一个MongoDB的知识点

    //WINForm窗体中切换前后台线程执行任务: protected void RunOnUI(Action action) { Invoke(action); } protected void Ru ...

  4. Spring AOP(4)

  5. Dangling Javadoc comment

    Javadoc主要用于对类和方法的注释.Javadoc没有@file和@date的注解.Javadoc has no @file or @date tags. You should be taggin ...

  6. Sharding-Jdbc实现分表分库

    Sharding-Jdbc分表分库LogicTable数据分片的逻辑表,对于水平拆分的数据库(表),同一类表的总称.订单信息表拆分为2张表,分别是t_order_0.t_order_1,他们的逻辑表名 ...

  7. Steema TeeChart Pro VCL FMX 2017.20 Full Suorce在Delphi XE10下的安装

    一.首先将压缩包TeeChart Pro VCL FMX 2017.20 FS.rar解压到一个目录,比如 E:\Application\Steema TeeChart Pro VCL FMX 201 ...

  8. spark 写hbase

    部分情况下: saveAsNewAPIHadoopDataset不能用 大坑, org.apache.hadoop.mapred 和 org.apache.hadoop.mapreduce两个包的混乱 ...

  9. Apache HTTP Server——官网下载

    Windows版 Apache 2.4.x OpenSSL 1.0.2 VC14  ——Apache 2.4.34 x64(注:x64就是64位,x86就是32位) https://www.apach ...

  10. Permutations,全排列

    问题描述:给定一个数组,数字中数字不重复,求所有全排列. 算法分析:可以用交换递归法,也可以用插入法. 递归法:例如,123,先把1和1交换,然后递归全排列2和3,然后再把1和1换回来.1和2交换,全 ...