列出不等式后,把同时除Z把它去掉。

注意了,这里应该 是把直线变两点表示的向量更为简单,我开始就直接用直线写,后来,唉,写不下去了。。

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
const int MAX=110;
const double eps=1e-10;
const double inf=1e10; struct point{
double x,y;
};
point operator -(point x,point y){
point t;
t.x=x.x-y.x; t.y=x.y-y.y;
return t;
} double operator *(point x,point y){
return x.x*y.y-x.y*y.x;
} struct line{
point a,b;
double angle;
};
int n,lnum;
double A[MAX],B[MAX],C[MAX];
line le[MAX],st[MAX]; int DB(double d){
if(fabs(d)<eps) return 0;
if(d>0) return 1;
return -1;
} void addLine(double x1,double y1,double x2,double y2){
point a; a.x=x1; a.y=y1;
point b; b.x=x2; b.y=y2;
le[lnum].a=a; le[lnum].b=b;
le[lnum].angle=atan2(y2-y1,x2-x1);
} bool cmp( line x, line y){
if(fabs(x.angle-y.angle)<eps){
if((y.b-x.a)*(x.b-y.a)>eps)
return true;
return false;
}
return x.angle<y.angle;
} void getIntersect(line l1, line l2, point& p) {
double dot1,dot2;
dot1 = (l1.b-l2.a)*(l1.a-l2.a);
dot2 = (l2.b-l1.b)*( l1.a-l1.b);
p.x = (l2.a.x * dot2 + l2.b.x * dot1) / (dot2 + dot1);
p.y = (l2.a.y * dot2 + l2.b.y * dot1) / (dot2 + dot1);
} bool judge(line l0, line l1, line l2) {
point p;
getIntersect(l1, l2, p);
return DB((l0.a-p)*(l0.b-p)) <=0;
} bool pare(line x,line y){
return fabs((x.b-x.a)*(y.b-y.a))<eps;
} bool half(){
int top=1,bot=0;
sort(le,le+lnum,cmp);
int tmp=1;
for(int i=1;i<lnum;i++){
if(fabs(le[i].angle-le[tmp-1].angle)>eps) le[tmp++]=le[i];
}
lnum=tmp;
st[0]=le[0]; st[1]=le[1];
for(int i=2;i<lnum;i++){
while(bot<top&&judge(le[i], st[top-1], st[top])) top--;
while(bot<top&&judge(le[i],st[bot+1],st[bot])) bot++;
st[++top]=le[i];
}
while(bot<top&&judge(st[bot],st[top-1],st[top])) top--;
while(bot<top&&judge(st[top],st[bot+1],st[bot])) bot++;
if(top<=bot+1) return false;
return true;
} bool slove(int s){
int i, j, k;
double x1, y1, x2, y2, a, b, c;
lnum=0;
addLine(0, 0, inf, 0 ); lnum++;
addLine(inf, 0, inf, inf ); lnum++;
addLine(inf, inf, 0, inf ); lnum++;
addLine(0, inf, 0, 0 ); lnum++;
for (j = 0; j < n; j++)
if (s != j) {
a = 1.0 / A[j] - 1.0 / A[s];
b = 1.0 / B[j] - 1.0 / B[s];
c = 1.0 / C[j] - 1.0 / C[s];
int d1 = DB(a);
int d2 = DB(b);
int d3 = DB(c);
if (!d1) {
if (!d2) {
if (d3 <= 0) {
return false;
}
continue;
}
x1 = 0;
x2 = d2;
y1 = y2 = - c / b;
}
else {
if (!d2) {
x1 = x2 = - c / a;
y1 = 0;
y2 = -d1;
}
else {
x1 = 0; y1 = - c / b;
x2 = d2;
y2 = -(c + a * x2) / b;
}
}
addLine(x1, y1, x2, y2 );
lnum++;
}
if(!half()) return false;
return true;
} int main(){
while(scanf("%d",&n)!=EOF){
for(int i=0;i<n;i++)
scanf("%lf%lf%lf",&A[i],&B[i],&C[i]);
for(int i=0;i<n;i++){
if(slove(i)) printf("Yes\n");
else printf("No\n");
}
}
return 0;
}

  

POJ 1755的更多相关文章

  1. poj 1755 半平面交+不等式

    Triathlon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6461   Accepted: 1643 Descrip ...

  2. POJ 1755 Triathlon

    http://poj.org/problem?id=1755 题意:铁人三项,每个人有自己在每一段的速度,求有没有一种3条路线长度都不为0的设计使得某个人能严格获胜? 我们枚举每个人获胜,得到不等式组 ...

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

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

  4. POJ 1755 Triathlon 半平面交

    看的这里:http://blog.csdn.net/non_cease/article/details/7820361 题意:铁人三项比赛,给出n个人进行每一项的速度vi, ui, wi;  对每个人 ...

  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. [转] POJ计算几何

    转自:http://blog.csdn.net/tyger/article/details/4480029 计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板 ...

  8. 【BZOJ】【2765】【JLOI2010】铁人双项比赛

    计算几何/半平面交 本来我是想去写POJ 1755的,然后想起了这道跟它很像的题,但应该是弱化版,所以就先写了这个…… 我们可以发现每个人的总用时,与k是呈一次函数关系的:$time_i=\frac{ ...

  9. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

随机推荐

  1. B3038 上帝造题的七分钟2 线段树

    这就是一道变得比较奇怪的线段树,维护每个区间的最大值和区间和,然后关键在于每次取根号的话数值下降的特别快,不用几次就都是1了,所以每次暴力单点修改,然后直接找区间最大值,假如区间最大值是1的话,就直接 ...

  2. treap平衡树

    今天集训讲平衡树,就瞎搞了一下.直接下代码. #include<iostream> #include<cstdio> #include<cmath> #includ ...

  3. bzoj 1050 [ HAOI 2006 ] 旅行comf —— 并查集

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1050 没思路的话想想暴力就好了... 首先,比值最小就是确定最小值后最大值最小: 怎样确定最 ...

  4. 学习XOR

    //f(x;W,c,w,b)=w*max{0, W*x+c}+b #include <iostream>#include <vector>#include <algori ...

  5. git 设定全局ignore

    创建: 2017/08/08   位置: $HOME/.config/git/ignore git/ignore 要自建 内容  https://github.com/github/gitignore ...

  6. Cash Machine(多重背包)

    http://poj.org/problem?id=1276 #include <stdio.h> #include <string.h> ; #define Max(a,b) ...

  7. css 浮动问题详解

    浮动(float),一个我们即爱又恨的属性.爱,因为通过浮动,我们能很方便地布局: 恨,浮动之后遗留下来太多的问题需要解决,特别是IE6-7(以下无特殊说明均指 windows 平台的 IE浏览器). ...

  8. bzoj 1503郁闷的出纳员(splay)

    1503: [NOI2004]郁闷的出纳员 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 11759  Solved: 4163[Submit][Stat ...

  9. C/C++中的绝对值函数

    --------开始-------- 对于不同类型的数据对应的绝对值函数也不相同,在c和c++中分别在头文件math.h 和 cmath 中. int : x = abs( n ) double : ...

  10. Django day11(一) ajax 文件上传 提交json格式数据

    一: 什么是ajax? AJAX(Asynchronous Javascript And XML)翻译成中文就是“异步Javascript和XML”.即使用Javascript语言与服务器进行异步交互 ...