博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
并查集 HDU1558
阅读量:4317 次
发布时间:2019-06-06

本文共 1936 字,大约阅读时间需要 6 分钟。

1 #include 
2 #include
3 #include
4 #include
5 6 using namespace std; 7 8 struct point 9 { 10 double x, y; 11 point( double _x = 0, double _y = 0 ) 12 { 13 x = _x; 14 y = _y; 15 } 16 point operator-( point t ) 17 { 18 return point( x - t.x, y - t.y ); 19 } 20 double operator*( point t ) 21 { 22 return x * t.y - y * t.x; 23 } 24 }; 25 26 //快速排斥试验模板 27 bool quickExclude( point a, point b, point c, point d ) 28 { 29 int x1 = a.x, x2 = b.x, x3 = c.x, x4 = d.x; 30 int y1 = a.y, y2 = b.y, y3 = c.y, y4 = d.y; 31 if ( min(x1,x2) <= max(x3,x4) && min(x3,x4) <= max(x1,x2) && 32 min(y1,y2) <= max(y3,y4) && min(y3,y4) <= max(y1,y2) ) 33 return true; 34 else return false; 35 } 36 37 //跨立试验模板(两线段(ab)和(cd)是否相交) 38 bool ifIntersect( point a, point b, point c, point d ) 39 { 40 if ( quickExclude( a, b, c, d ) ) 41 { 42 if ( ( ( a - c ) * ( c - d ) ) * ( ( b - c ) * ( c - d ) ) <= 0 && ( ( c - a ) * ( a - b ) ) * ( ( d - a ) * ( a - b ) ) <= 0 ) 43 return true; 44 } 45 return false; 46 } 47 48 set
ss; 49 int father[1010]; 50 int num[1010]; 51 point arr[1010][2]; 52 53 int main() 54 { 55 int T; 56 cin>>T; 57 for(int y=0;y
>n; 67 int time=1; 68 char c; 69 double x1,y1,x2,y2; 70 for(int i=0;i
>c; 74 if(c=='P') 75 { 76 cin>>x1>>y1>>x2>>y2; 77 arr[time][0].x=x1; 78 arr[time][0].y=y1; 79 arr[time][1].x=x2; 80 arr[time][1].y=y2; 81 for(int t=1;t
>se;106 int fse=se;107 while(fse!=father[fse])108 {109 fse=father[fse];110 }111 int j=se;112 while(j!=fse)113 {114 int tmp=father[j];115 father[j]=fse;116 j=tmp;117 }118 cout<
<
View Code

 

转载于:https://www.cnblogs.com/wsruning/p/4719083.html

你可能感兴趣的文章
codeforces Unusual Product
查看>>
hdu4348 - To the moon 可持久化线段树 区间修改 离线处理
查看>>
springMVC中一个class中的多个方法
查看>>
Linux系统安装出错后出现grub rescue的修复方法
查看>>
线段树模板整理
查看>>
[教程][6月4日更新]VMware 8.02虚拟机安装MAC lion 10.7.3教程 附送原版提取镜像InstallESD.iso!...
查看>>
[iOS问题归总]iPhone上传项目遇到的问题
查看>>
Python天天美味(总) --转
查看>>
Spring Framework tutorial
查看>>
【VS开发】win7下让程序默认以管理员身份运行
查看>>
【机器学习】Learning to Rank 简介
查看>>
Unity 使用实体类
查看>>
【转】通过文件锁实现,程序开始运行时,先判断文件是否存在,若存在则表明该程序已经在运行了,如果不存在就用open函数创建该文件,程序退出时关闭文件并删除文件...
查看>>
MySQL常见注意事项及优化
查看>>
流畅的Python (Fluent Python) —— 前言
查看>>
Jquery-menu-aim流畅的菜单滑动体验
查看>>
Jquery EasyUI修改行背景的两种方式
查看>>
生成器模式(Builder)C++实现
查看>>
Centos 7.5安装 Redis 5.0.0
查看>>
嵌入式Linux学习笔记(0)基础命令。——Arvin
查看>>