题意

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. Arrays.asList()与toArray()

    Arrays.asList() 使用Arrays.asList()把数组转换成集合时,不能使用用于修改集合的方法(例如add.remove.clear),这将导致跑出UnsupportOperatio ...

  2. PHP面向对象程序设计之接口(interface)

    接口(interface)是抽象方法和静态常量定义的集合.接口是一种特殊的抽象类,这种抽象类中只包含抽象方法和静态常量. 为什么说接口是一种特殊的抽象类呢?如果一个抽象类里面的所有的方法都是抽象方法, ...

  3. 20145217《信网络对抗》逆向与BOF基础实践

    20145217<信网络对抗>逆向与BOF基础实践 内容: 一.简单机器指令,汇编语言 1.'objdump -d xxx|more'反汇编命令查看机器代码,'cat'显示文件内容,'xx ...

  4. BUG: scheduling while atomic 分析【转】

    本文转载自:https://blog.csdn.net/cfy_phonex/article/details/12090943 遇到一个典型的schedule问题.   <3>[26578 ...

  5. 解决Vim插入模式下backspace按键无法删除字符的问题【转】

    本文转载自:https://blog.csdn.net/zxy987872674/article/details/64124959 最近使用某个服务器编辑文件时,快捷键i进入插入模式后,下方不出现in ...

  6. SpringBoot ControllerAdvice

    在Spring3.2中新增了@ControllerAdvice注解,可用于定义@ExceptionHandler @ModelAttribute @InitBinder,并应用到所有被@Request ...

  7. Spring_配置 Bean(1)

  8. 《大型网站系统与JAVA中间件实践》读书笔记-大型网站架构演进

    大型网站架构演进 大型网站是一种很常见的分布式系统,除了海量数据和高并发的访问量,本身业务和系统也复杂. 大型网站的架构演进 我们现在常用的大型网站都是从小网站一步一步发展起来的,这个过程中会 有一些 ...

  9. scala学习手记9 - =和==

    = 赋值运算 scala的赋值运算和java的有着很大的不同.如a=b这样的赋值运算,在Java中返回值是a的值,在scala中返回的则是Unit(Unit是值类型,全局只存在唯一的值,即(),通常U ...

  10. Ajax基础(三)--eval的使用

    eval的使用: 1.定义和用法 计算某个字符串,并执行其中的js代码 eval(string) string必须,含有表达式或执行语句 string有返回值的话 2.实例 2.1 字符串上该用eva ...