国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

bzoj 3800: Saber VS Lancer (半平面交求解不等式組)

2019-11-08 18:34:29
字體:
來源:轉載
供稿:網友

3800: Saber VS Lancer

Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 71  Solved: 27[Submit][Status][Discuss]

Description

鐵人三項是一種運動項目,和字面意思一樣,是讓鐵做的人(?)去做三個項目,必須連續完成,而且全程講求速度。第一項是游泳,第二項是騎自行車,第三項是跑步。現在所有選手的三個項目的速度都是已知的。但是這次比賽中,裁判可以任意選擇每一個項目的路程長度(假設沒有一項長度為0)。但是這樣顯然會影響比賽排名……有時她會按某種方式選擇,使得一些個別的選手能贏得競賽。

Input

首行為運動員的人數N (1 ≤ N ≤ 100,80%的數據中n<=20),以下N行,每行含3個整數,Vi, Ui 和Wi (1 ≤ Vi, Ui, Wi ≤ 10000),用空格隔開,表示各人3個項目的速度。 

Output

對于每個運動員,都用一行輸出,假如裁判以某種方式選擇的路程會使得他贏(即第一個沖線,同時抵達不算贏),則輸出“Yes”,否則輸出“No”  。

Sample Input

910 2 610 7 35 6 73 2 76 2 63 5 78 4 610 4 21 8 7

Sample Output

YesYesYesNoNoNoYesNoYes

HINT

Source

[Submit][Status][Discuss]

題解:半平面交求解不等式組

#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#define N 103#define eps 1e-16#define inf 1000000000using namespace std;struct vector {    double x,y;    vector (double X=0,double Y=0){        x=X,y=Y;    }}a1[N],p[N],tmp[N];typedef vector point;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 t){    return vector (a.x*t,a.y*t);}vector operator !=(vector a,vector b){    return a.x!=b.x||a.y!=b.y;}struct data{    point a,b;}line[N];double a[N],b[N],c[N];int n,m;void init(){    m=0;    p[m++]=point(inf,inf);    p[m++]=point(eps,inf);    p[m++]=point(eps,eps);    p[m++]=point(inf,eps);}int dcmp(double x){    if (fabs(x)<eps) return 0;    return x<0?-1:1;}double cross(vector a,vector b){    return a.x*b.y-a.y*b.x;}point glt(point a,point a0,point b,point b0){    double a1,b1,c1,a2,b2,c2;      a1 = a.y - a0.y;      b1 = a0.x - a.x;      c1 = cross(a,a0);      a2 = b.y - b0.y;      b2 = b0.x - b.x;      c2 = cross(b,b0);      double d = a1 * b2 - a2 * b1;      return point((b1 * c2 - b2 * c1) / d,(c1 * a2 - c2 * a1) / d);   }void cut(point a,point b){    int cnt=0;    memset(tmp,0,sizeof(tmp));    for (int i=0;i<m;i++){        double c=cross(b-a,p[i]-a);        double d=cross(b-a,p[(i+1)%m]-a);        if (dcmp(c)>=0)           tmp[cnt++]=p[i];        if (dcmp(c)*dcmp(d)<0)          tmp[cnt++]=glt(a,b,p[i],p[(i+1)%m]);    }    m=0;    for (int i=0;i<cnt;i++)      if (m==0 || (tmp[i].x!=p[m-1].x||tmp[i].y!=p[m-1].y))        p[m++]=tmp[i];}int main(){    scanf("%d",&n);    for (int i=1;i<=n;i++) scanf("%lf%lf%lf",&a[i],&b[i],&c[i]);    for (int i=1;i<=n;i++){        int k=0;        bool mark=true;        for (int j=1;j<=n;j++){            if (i==j) continue;            double nowa=1.0/a[j]-1.0/a[i];            double nowb=1.0/b[j]-1.0/b[i];            double nowc=1.0/c[j]-1.0/c[i];            if (dcmp(nowa)==0&&dcmp(nowb)==0) {                if (dcmp(nowc)>0) continue;                else {                    mark=false;                    break;                }            }            k++;            if (dcmp(nowb)==0) {                double t=-nowc/nowa;                line[k].a.x=t; line[k].b.x=t;                line[k].a.y=1; line[k].b.y=2;                if (dcmp(nowa)>0) swap(line[k].a,line[k].b);                continue;            }            line[k].a.x=1;            line[k].a.y=-(nowa+nowc)/nowb;            line[k].b.x=2;            line[k].b.y=-(nowa*2.0+nowc)/nowb;            if (dcmp(nowb)<0) swap(line[k].a,line[k].b);        }        if (!mark){            PRintf("No/n");            continue;        }        init();        for (int  j=1;j<=k;j++)         cut(line[j].a,line[j].b);        double area=0; p[m]=p[0];        for (int j=1;j<m;j++) area+=cross(p[j]-p[0],p[j+1]-p[0]);        area=fabs(area);        if (m>2&&dcmp(area)>0) printf("Yes/n");        else printf("No/n");    }}


上一篇:mutable

下一篇:定時器的實現

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 晋城| 建水县| 丰城市| 台州市| 华蓥市| 庐江县| 高密市| 临泽县| 盐边县| 林芝县| 汕尾市| 安远县| 巴里| 正定县| 栾川县| 和静县| 安乡县| 九龙城区| 仁化县| 黄陵县| 永吉县| 涡阳县| 乌苏市| 鄂托克旗| 桂林市| 庆城县| 额敏县| 华容县| 泰安市| 安新县| 洛扎县| 东乡县| 水城县| 弥渡县| 仙居县| 福鼎市| 安溪县| 漳州市| 张家口市| 盱眙县| 勃利县|