POJ——T2117 Electricity】的更多相关文章

 http://poj.org/problem?id=2117 Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5459   Accepted: 1788 当m==0 时,特判输出 n-1~~~ 先求出原始的连通分量, 然后只有删割点才会增加连通分量,枚举每个割点 最后加上原始的 #include <algorithm> #include <cstring> #include <cstdio> u…
Electricity Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4727   Accepted: 1561 Description Blackouts and Dark Nights (also known as ACM++) is a company that provides electricity. The company owns several power plants, each of them sup…
http://poj.org/problem?id=2117 题意:求删除图中任意一个顶点后的最大连通分量数. 思路: 求出每个割点对应的连通分量数,注意这道题目中图可能是不连通的. 这道题目我wa了很多发,主要是我忘了根结点的连通分量数得减1. 为什么呢?因为如果我们用cut[]来记录每个结点对应的连通分量数的话,最后的答案还需要加1. 比如2结点,我们计算所得的cut[2]=3,因为它只计算了它的子树的情况,但是父亲结点并没有计算进去,所以最后需要+1,这个1也就是父亲结点方向也会产生一个连…
http://poj.org/problem?id=2117 这个妹妹我竟然到现在才见过,我真是太菜了~~~ 求去掉一个点后图中最多有多少个连通块.(原图可以本身就有多个连通块) 首先设点i去掉后它的子树(我知道不准确但是领会精神就好了吧orz)能分成cut[i]个连通块,那么除了根节点之外去掉任意一个点就多出cut[i]个联通块(根节点多出cut[i]-1个连通块). (简洁的语言说cut[i]表示的就是i点是多少个点双连通分量的割顶,我连割顶都忘了是什么了嘤嘤嘤) 每个点只遍历一次且一定在所…
Electricity Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5620   Accepted: 1838 Description Blackouts and Dark Nights (also known as ACM++) is a company that provides electricity. The company owns several power plants, each of them sup…
题目链接:http://poj.org/problem?id=2117 题意:求删除一个点后,图中最多有多少个连通块. 题解:就是找一下割点,根节点的割点删掉后增加son-1(son为子树个数),非根节点删掉之后++ #include <iostream> #include <cstring> #include <cstdio> using namespace std; const int N = 1e4 + 10; const int M = 1e6 + 10; st…
/* Tarjan求割点 */ #include<iostream> #include<cstdio> #include<cstring> #include<stack> #define maxn 10010 using namespace std; int n,m,num,head[maxn],low[maxn],dfn[maxn],f[maxn],father[maxn]; int point[maxn],topt,sum; struct node{ i…
Electricity POJ - 2117 题目描述 Blackouts and Dark Nights (also known as ACM++) is a company that provides electricity. The company owns several power plants, each of them supplying a small area that surrounds it. This organization brings a lot of proble…
无向图求割点和连通块. /* POJ2117 */ #include <iostream> #include <vector> #include <algorithm> #include <cstdio> #include <cstring> #include <cstdlib> using namespace std; #define MAXN 10005 vector<int> vc[MAXN]; int low[MA…
Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798   Special Judge Description Every year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets…