UVALive 2218

#define eps 1e-17
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct point{
    double x,y;
}p[210],s[210];
struct person{
    double u,v,w;
    void init(){
        scanf("%lf%lf%lf",&v,&u,&w);
    }
}h[210];
double A,B,C;
double cal(point e){
    return A*e.x+B*e.y+C;
}
point insert(point a,point b){
    point as;
    double t1=fabs(cal(a)),t2=fabs(cal(b));
    as.x=(t2*a.x+t1*b.x)/(t2+t1);
    as.y=(t2*a.y+t1*b.y)/(t2+t1);
    return as;
}

void hfplncut(int& len){
    int i,tc=0;
    for(i=0;i<=len;i++)p[i]=s[i];
    for(i=0;i<len;i++){
        if(cal(p[i])<-eps)s[tc++]=p[i];
        if(cal(p[i+1])*cal(p[i])<-eps)
            s[tc++]=insert(p[i+1],p[i]);
    }
    s[tc]=s[0];
    len=tc;
}
int main(){
 //   freopen("in.txt","r",stdin);
 //   freopen("out.txt","w",stdout);
    int i,j,n,m;
    while(~scanf("%d",&n)){
        for(i=0;i<n;i++)
            h[i].init();
        for(i=0;i<n;i++){
            s[0].x=eps;s[0].y=eps;
            s[1].x=1e8;s[1].y=eps;
            s[2].x=1e8;s[2].y=1e8;
            s[3].x=eps;s[3].y=1e8;
            s[4].x=eps;s[4].y=eps;
            m=4;
            for(j=0;j<n;j++)if(i!=j){
                C=(h[j].w-h[i].w)/(h[i].w*h[j].w);
                A=(h[j].v-h[i].v)/(h[i].v*h[j].v);
                B=(h[j].u-h[i].u)/(h[i].u*h[j].u);
                hfplncut(m);
            }
            puts(m?"Yes":"No");
        }
    }
    return 0;
}

你可能感兴趣的:(UVALive 2218)