题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1558 题意:P为画线段,Q为询问当前这条线段所在的集合有多少线段 题解:如果两条线段有交点,那么就连接这两个集合 #include<cstdio> #define FFC(i,a,b) for(int i=a;i<=b;++i) ]; ];;]; int is(line a,line b){ ; ; ; } int find(int x){return f[x]==x?x:(f[x]=fin…
传送门 这个直接用并查集维护. 每加入一条线段就将它与其他能相交的集合合并,维护一个size" role="presentation" style="position: relative;">sizesize域表示每个集合的大小. 代码: #include<bits/stdc++.h> #define eps 1e-15 using namespace std; int t,fa[1005],n,siz[1005],cnt; struct…
在一些有N个元素的集合应用问题中,我们通常是在开始时让每个元素构成一个单元素的集合,然后按一定顺序将属于同一组的元素所在的集合合并,其间要反复查找一个元素在哪个集合中.这一类问题其特点是看似并不复杂,但数据量极大,若用正常的数据结构来描述的话,往往在空间上过大,计算机无法承受:即使在空间上勉强通过,运行的时间复杂度也极高,根本就不可能在规定的运行时间(1-3秒)内计算出试题需要的结果,只能用并查集来描述. 本文地址:http://www.cnblogs.com/archimedes/p/disj…
转自:http://blog.csdn.net/shahdza/article/details/7779230 [HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More is better 基础并查集★1102 Constructing Roads 基础最小生成树★1232 畅通工程 基础并查集★2120 Ice_cream's world I 基础并查集★212…
Jack Straws In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned with if various pairs of straws are…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3521 ATTENTION:如果用long long 减小误差,这道题只能用%lld读入 首先需要判断哪些点是相互挨着的,这样比直接维护哪些集合是冰冻住的简单 按照x为主,y为辅排序,在数组上尺取,当head与tail的x坐标相差大于l/2则把head向后移动直到x坐标满足条件, 那么对于head到tail,现在的问题就只剩下检测出哪些点之间y间距小于l/2,把它们都按照p…
Segment set Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4479    Accepted Submission(s): 1672 Problem Description A segment and all segments which are connected with it compose a segment set.…
http://codeforces.com/gym/100625/attachments/download/3213/2013-benelux-algorithm-programming-contest-bapc-13-en.pdf 题意:平面内给你一个y轴为左边界,宽度为w的长条形区域,区域内n个半径为r的圆,问你最大能够通过这个区域的圆的半径是多少. 思路:这题和POJ 3798差不是很多,感觉像是简化版.之前鲍佳提到过那个题,谈到过并查集,不过我没写过.知道并查集这题就很好想了,在圆与圆,…
<传送门> 128. Snake time limit per test: 0.25 sec. memory limit per test: 4096 KB There are N points given by their coordinates on a plane. All coordinates (xi,yi) are integers in a range from -10000 up to 10000 inclusive . It is necessary to construct…
简单的计算几何题,判断两线段是否相交.将相交的两线段使用并查集归到一类中.查询时输出线段对应集合中元素的个数. #include<stdio.h> struct Point{ double x,y; }; struct Segment{ Point s,e; }node[1010]; int n,parent[1010]; int getAbs(int value) { if(value>=0)return value; return -value; } int getParent(in…