题目地址:ZOJ 2588 由于数组开小了而TLE了..这题就是一个求无向连通图最小割边.仅仅要推断dfn[u]是否<low[v],由于low指的当前所能回到的祖先的最小标号,增加low[v]大于dfn[u]时,说明v无法通过其它边回到u之前的点.也就是说v假设想要回到u的祖先点.必需要经过u点,那这条边非常明显就是一条割边.这题还要去重边,假如有重边的话.说明怎么销毁哪条边总能通过还有一条边,所以仅仅要有重边.说明这两点之间没有割边. 代码例如以下: #include <iostream&g…
点击打开链接 题目链接:   hdu 4738 题目大意:   曹操有N个岛,这些岛用M座桥连接起来 每座桥有士兵把守(也可能没有) 周瑜想让这N个岛不连通,但只能炸掉一座桥 并且炸掉一座桥需要派出不小于守桥士兵数的人去 解题思路:   首先判断图是否连通,不连通则不需要去炸桥,输出0 图连通,则可以用Tarjan找割边 割边不存在输出-1表示不能达到目的 找到所有的割边,只需要炸掉其中守兵数最少的桥即可 PS: 桥的守兵数为0时,也需要派出一个人去炸桥! 求桥的第一种写法: #include"…
Network Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7082   Accepted: 2555 Description A network administrator manages a large network. The network consists of N computers and M links between pairs of computers. Any pair of computers…
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1588 吐下槽,不得不说ZOJ好坑,模版题做了一个多小时. 题意:*        给出一个无向图,输入n(表示n个定点,1~n), m(m条边,有重边),*        (2 <= N <= 10 000, 1 <= M <= 100 000),求这个无向图中的桥,*        并输出桥属于输入中边的id. 之前学图的连通性因为没看懂双连通分量,就把…
 Caocao's Bridges Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4738 Description Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But he wouldn't give up. Caocao's army s…
Burning Bridges Time Limit: 5 Seconds Memory Limit: 32768 KB Ferry Kingdom is a nice little country located on N islands that are connected by M bridges. All bridges are very beautiful and are loved by everyone in the kingdom. Of course, the system o…
poj2117 Electricity Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 3603   Accepted: 1213 Description Blackouts and Dark Nights (also known as ACM++) is a company that provides electricity. The company owns several power plants, each of…
题目:http://poj.org/problem?id=1523 题目解析: 注意题目输入输入,防止PE,题目就是求割点,并问割点将这个连通图分成了几个子图,算是模版题吧. #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <stack> #include <string> #define N 10010…
题目大意:双向联通图, 现在求减少任意一边使图的联通性改变,按照起点从小到大列出所有这样的边 解题思路:双向边模版题 tarjan算法 代码如下: #include<bits/stdc++.h> using namespace std; ; vector<int>vec[N]; pair<int, int>edge[N]; int dfn[N], low[N]; int res, ans; void tarjan(int u, int f) { dfn[u] = low…
题目:http://poj.org/problem?id=1144 求割点.判断一个点是否是割点有两种判断情况: 如果u为割点,当且仅当满足下面的1条 1.如果u为树根,那么u必须有多于1棵子树 2.如果u不为树根,那么(u,v)为树枝边,当Low[v]>=DFN[u]时. 然后根据这两句来找割点就可以了. 模版题,就是题意看不懂.看了题解.这题算是废了,就当贴模版用吧. #include <iostream> #include <stdio.h> #include <…