博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 2117 求无向图的割点
阅读量:5296 次
发布时间:2019-06-14

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

Electricity
Time Limit: 5000MS   Memory Limit: 65536K
Total Submissions: 4332   Accepted: 1419

Description

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 problems - it often happens that there is not enough power in one area, while there is a large surplus in the rest of the country. 
ACM++ has therefore decided to connect the networks of some of the plants together. At least in the first stage, there is no need to connect all plants to a single network, but on the other hand it may pay up to create redundant connections on critical places - i.e. the network may contain cycles. Various plans for the connections were proposed, and the complicated phase of evaluation of them has begun. 
One of the criteria that has to be taken into account is the reliability of the created network. To evaluate it, we assume that the worst event that can happen is a malfunction in one of the joining points at the power plants, which might cause the network to split into several parts. While each of these parts could still work, each of them would have to cope with the problems, so it is essential to minimize the number of parts into which the network will split due to removal of one of the joining points. 
Your task is to write a software that would help evaluating this risk. Your program is given a description of the network, and it should determine the maximum number of non-connected parts from that the network may consist after removal of one of the joining points (not counting the removed joining point itself). 

Input

The input consists of several instances. 
The first line of each instance contains two integers 1 <= P <= 10 000 and C >= 0 separated by a single space. P is the number of power plants. The power plants have assigned integers between 0 and P - 1. C is the number of connections. The following C lines of the instance describe the connections. Each of the lines contains two integers 0 <= p1, p2 < P separated by a single space, meaning that plants with numbers p1 and p2 are connected. Each connection is described exactly once and there is at most one connection between every two plants. 
The instances follow each other immediately, without any separator. The input is terminated by a line containing two zeros. 

Output

The output consists of several lines. The i-th line of the output corresponds to the i-th input instance. Each line of the output consists of a single integer C. C is the maximum number of the connected parts of the network that can be obtained by removing one of the joining points at power plants in the instance.

Sample Input

3 30 10 22 14 20 12 33 11 00 0

Sample Output

122

Source

题意:给定一个无向图,求删除一个节点后,使得图的连通分量的数量最多;
解题思路:
1.求割点,答案=初始图的连通分量数+割边数;
2.if(m==0) ans=n-1;
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 using namespace std; 9 const int maxn=11007;10 vector
G[maxn];11 int pre[maxn],ans,root,sum,n,m,cnt[maxn];12 int tarjan(int u,int fa)13 {14 int lowu=pre[u]=sum++;15 int l=G[u].size();16 int child=0;17 for(int i=0;i
1)||(u!=root&&pre[u]<=lowv)){26 cnt[u]++;27 }28 }29 else lowu=min(lowu,pre[v]);30 }31 return lowu;32 }33 int main()34 {35 int a,b;36 while(1){37 for(int i=0;i

 

转载于:https://www.cnblogs.com/codeyuan/p/4385728.html

你可能感兴趣的文章
SqlBulkCopy大批量导入数据
查看>>
HTTP协议 (四) 缓存
查看>>
python学习之random
查看>>
【转载】测试计划模板
查看>>
pandas 修改指定列中所有内容
查看>>
ubuntu18.04 复制或剪切某文件夹下的前x个文件到另一个文件夹下
查看>>
input的value中有特殊字符
查看>>
字符串压缩
查看>>
用Lua定制Redis命令
查看>>
小程序-canvas在IOS手机层级最高无法展示问题
查看>>
「 Luogu P2285 」打鼹鼠
查看>>
lua语言入门之Sublime Text设置lua的Build System
查看>>
解决win8使用内置管理员不能打开应用商城、天气等问题
查看>>
vue.js基础
查看>>
电脑的自带图标的显示
查看>>
globalization与全球化
查看>>
[转载] redis 的两种持久化方式及原理
查看>>
关于在Idea 创建Maven项目时,无法在source文件下创建servlet文件问题解决!
查看>>
对 HTTP 304 的理解
查看>>
深入理解css中的margin属性
查看>>