#include<iostream> //由于拆除并查集的方法太难或者没有#include<cstdio> //可以先将所有没有拆的桥连接 再逆向操作 断开变成连接 反向输出#include<map> using namespace std; const int Hash = 10000;const int N = 10005;const int M = 20005; map<int, bool>mp; //mp用来标记该桥是否会被拆,如果会被拆就先不要连接…
Connections in Galaxy War In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War began, some tunnels were destroyed by the monsters from…
http://acm.hdu.edu.cn/showproblem.php?pid=4496 题意: 给出n个顶点m条边的图,每次选择一条边删去,求每次删边后的连通块个数. 思路: 离线处理删边,从后往前处理变成加边,用并查集维护连通块个数.其实这题和BZOJ 1015差不多. #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n, m, tot, num; ],…
Connections in Galaxy War Time Limit: 3 Seconds Memory Limit: 32768 KB 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3261 Description: In order to strengthen the defense ability, many stars in galaxy allied together and built…
City Park 题目连接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=122283#problem/F Description Porto is blessed with a beautiful city park. The park, in the western section of the city, borders the Atlantic Ocean. It has great lawns, small forest…
Connections in Galaxy War http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3563 Time Limit: 3 Seconds Memory Limit: 32768 KB In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional…
貌似某大犇说过 正难则反,,, 题目说要对这张图进行删边,然后判断联通块的个数,那么就可以先把所有边都删掉,之后从后往前加边,若加的边两端点不在同一个联通块中, 那么此时联通快个数少一,否则不变 #include <cstdio> #include <cstring> #include <algorithm> + ; + ; int father[maxn]; int x1[maxm], x2[maxm]; int ans[maxm]; int n, m; int ge…
转自: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…
并查集的介绍可以看下https://www.cnblogs.com/jkzr/p/10290488.html A - Wireless Network POJ - 2236 An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected afters…
City Park Problem's Link: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=129725 Mean: 在网格中给你一些矩形,求最大连通块的面积. analyse: 由于题目保证了矩形不会相交,所以不用扫描线也可做. 先把所有的线段分为横向和纵向,然后排序,依次判断是否相邻,相邻就用并查集合并,最后再用并查集统计一下面积,取最大值即可. Time complexity: O(N) Source code…
题意: 给你一些点,还有一些边,每个点上都有一个权值,然后有一些询问,分为两种, query a 询问与a直接或者间接想连的点中最大权值的是那个点,输出那个点,如果那个点的权值小于等于a的权值,那么就输出-1,还有另一种操作就是destroy a b意思是删除a b的关系. 思路: 比较基础的并查集题目,看到删边,很容易想到逆向离线处理,先把最终的状态建立出来,然后对于询问逆向处理,正向是删边,那么逆向肯定是加边了,更新最优的话也是比较简单的并查集小变种(也就是平时说的带…
D-City Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 1315 Accepted Submission(s): 496 Problem Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D…
Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42416 Accepted: 13045 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Drago…
传送门 Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42463 Accepted: 13065 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang D…
FZU 2112 Tickets Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Practice Description You have won a collection of tickets on luxury cruisers. Each ticket can be used only once, but can be used in either direction betwee…