HDU 2150 Pipe( 判断线段相交水 )
2024-08-31 11:02:42
**链接:****传送门 **
题意:略
思路:数据量很小,直接暴力所有线段
/*************************************************************************
> File Name: hdu2150.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年05月07日 星期日 23时09分58秒
************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-10
struct point{ double x,y; };
bool inter(point a,point b,point c,point d){
if( min(a.x,b.x) > max(c.x,d.x) ||
min(a.y,b.y) > max(c.y,d.y) ||
min(c.x,d.x) > max(a.x,b.x) ||
min(c.y,d.y) > max(a.y,b.y) ) return 0;
double h , i , j , k;
h = (b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x);
i = (b.x - a.x)*(d.y - a.y) - (b.y - a.y)*(d.x - a.x);
j = (d.x - c.x)*(a.y - c.y) - (d.y - c.y)*(a.x - c.x);
k = (d.x - c.x)*(b.y - c.y) - (d.y - c.y)*(b.x - c.x);
return h*i<=eps && j*k<=eps;
}
int main(){
int N,num[31];
point pi[31][101];
while(~scanf("%d",&N)){
for(int i=0;i<N;i++){
scanf("%d",&num[i]);
for(int j=0;j<num[i];j++){
scanf("%lf%lf",&pi[i][j].x,&pi[i][j].y);
}
}
bool ok = false;
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
for(int k=0;k<num[i]-1;k++){
for(int s=0;s<num[j]-1;s++){
if( inter(pi[i][k],pi[i][k+1],pi[j][s],pi[j][s+1])){
ok = true; break;
}
}
}
}
}
if(ok) printf("Yes\n");
else printf("No\n");
}
return 0;
}
最新文章
- C语言基于GTK+Libvlc实现的简易视频播放器
- 【读书笔记】iOS-数据交换格式
- 【USACO 1.4】Arithmetic Progressions
- n全排列输出和 n个数的组合(数字范围a~b)
- Dynamic CRM 2013学习笔记(三十八)流程1 - 操作(action)开发与配置详解
- Leetcode 204 Count Primes 数论
- Jquery 格式化时间
- linux 压缩文件 及压缩选项详解
- libevent的使用方法--回显服务器的简单实例
- MySQL简单查询
- Android应用开发基础篇(6)-----Service
- iOS:获取图片Alpha图片
- sql 通过存储过程和自定义类型批量新增数据
- 共享MFC每周时间选择控件代码
- 委托的多线程方法BeginInvoke
- 005-CSS让页脚始终在底部不论页面内容多少
- Test Scenarios for result grid
- ERROR 1526 (HY000): Table has no partition for value xxx
- Unity3D之Lightmap详解
- 为什么要重写hashCode()方法和equals()方法及如何重写
热门文章
- C++基础 (7) 第七天 多态的原理 纯虚函数和抽象类 依赖倒置原则
- 为什么在JavaScript中0.1+0.2不等于0.3?
- nyoj314-斐波那契数列四吧
- 把SQLAlchemy查询对象转换成字典/json使用(汇总)
- 3.2、使用Flask-Bootstrap集成Twitter Bootstrap
- prim求最小生成树
- 【CodeForces 271D】Good Substrings
- (OpenExplorer For Eclipse)Eclipse 中打开工程目录的插件(转)
- PowerDesigner16 破解
- [Tailwind] Apply mobile-first Responsive Classes in Tailwind