传送门: http://acm.hdu.edu.cn/showproblem.php?pid=3367 Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3242    Accepted Submission(s): 1273 Problem Description In graph theory, a pseu…
Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2311    Accepted Submission(s): 892 Problem Description In graph theory, a pseudoforest is an undirected graph in which every conne…
http://acm.hdu.edu.cn/showproblem.php?pid=3367 题目大意 伪森林就是一个无向图,这个无向图有多个连通块且每个连通块只有一个简单环. 给你一个无向图,让你找这个图的一个最大生成伪森林(即边权之和最大). 题解 考虑到用Kruscal算法搞最大生成树时,每次加入一条边之前都必须保证边的这两点在之前属于两个连通块,就是为了防止出现环. 即如果加入的边的两点在一个没有环的连通块里的话,就会出现一个环. 那么我们把Kruscal算法改造一下,如果这条边的两点在…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3367 Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2870    Accepted Submission(s): 1126 Problem Description In graph theory, a pseu…
题目链接:http://icpc.njust.edu.cn/Problem/Hdu/3367/ 题目要求一个连通图的最大伪森林,伪森林是一个最多有一个回路的图.我们只要用Kruskal最大生成树的策略就可以,给根节点表上记号表明这棵树有没有负环.其实也有一些贪心的思想. 代码如下: #include<bits/stdc++.h> using namespace std; typedef unsigned int ui; typedef long long ll; typedef unsigne…
Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1526    Accepted Submission(s): 580 Problem Description In graph theory, a pseudoforest is an undirected graph in which every connec…
题意:有一种叫作Pseudoforest的结构,表示在无向图上,每一个块中选取至多包含一个环的边的集合,又称“伪森林”.问这个集合中的所有边权之和最大是多少? 分析:如果没有环,那么构造的就是最大生成森林,在此基础上,只要取每个块中剩余边的最大边,必然得到结果.不过要构造出每条边归属于哪个块.  看了别人的代码,发现原来可以直接构造出一个标记数组记录环,在做并查集的时候扩充if(find(u)==find(v))这一条件,可以直接得到结果. #include<cstdio> #include&…
Pseudoforest Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 389 Accepted Submission(s): 165   Problem Description In graph theory, a pseudoforest is an undirected graph in which every connected…
Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1705    Accepted Submission(s): 653 Problem Description In graph theory, a pseudoforest is an undirected graph in which every conne…
并查集. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 10005 #define INF 0xffffff typedef struct { int c, s, e; } edge_st; edge_st edges[]; int pre[MAXN]; int deg[MAXN]; int n, m, ans; int comp(const void *a, const voi…