列出不等式后,把同时除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. 603E

    LCT维护MST+子树信息 看了好长时间题解 editorial 结论:像做最小生成树一样,当每个连通块都是偶数个点就停下来. 每次复杂度mlogm 口胡 首先我们发现奇数个点是不满足每个点度数为奇数 ...

  2. Github标星4W+,热榜第一,如何用Python实现所有算法

    文章发布于公号[数智物语] (ID:decision_engine),关注公号不错过每一篇干货. 来源 | 大数据文摘(BigDataDigest) 编译 | 周素云.蒋宝尚 学会了 Python 基 ...

  3. 自学Python六 爬虫基础必不可少的正则

    要想做爬虫,不可避免的要用到正则表达式,如果是简单的字符串处理,类似于split,substring等等就足够了,可是涉及到比较复杂的匹配,当然是正则的天下,不过正则好像好烦人的样子,那么如何做呢,熟 ...

  4. VUE-搜索过滤器

    先看看效果 首先引入 <script src="https://cdn.jsdelivr.net/npm/vue"></script> HTML部分 < ...

  5. python--5、模块

    模块 程序的代码根据作用分散写入多个文件,这些文件相互引用,以实现程序的功能,这些文件即称之为”模块“.自己定义的函数或者变量为了防止在解释器中执行完退出后丢失,需要把代码写到文件中,再直接执行,称为 ...

  6. QS之force(3)

    Example in project - First force signals in certain time and then noforce signals after some time. # ...

  7. 【sqli-labs】 less23 Error based - strip comments (GET型基于错误的去除注释的注入)

    . 加单引号报错 加# http://localhost/sqli-labs-master/Less-23/?id=1'%23 错误没有改变,推测过滤了# 查看源码发现# -- 都被替换掉了 那么可用 ...

  8. js 响应事件

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  9. The remote certificate is invalid according to the validation procedure 远程证书验证无效

    The remote certificate is invalid according to the validation procedure   根据验证过程中远程证书无效 I'm calling ...

  10. eas之kdtable格式化

    设置表.列.行或单元的格式化字符串 // 设置表table.getStyleAttributes().setNumberFormat(formatString); // 设置列column.getSt ...