ACM: 图论题 poj 3352 双连通题
来源:互联网 发布:win7如何安装linux系统 编辑:程序博客网 时间:2024/05/17 17:44
Description
It's almost summer time, and that means that it's almost summerconstruction time! This year, the good people who are in charge ofthe roads on the tropical island paradise of Remote Island wouldlike to repair and upgrade the various roads that lead between thevarious tourist attractions on the island.
The roads themselves are also rather interesting. Due to thestrange customs of the island, the roads are arranged so that theynever meet at intersections, but rather pass over or under eachother using bridges and tunnels. In this way, each road runsbetween two specific tourist attractions, so that the tourists donot become irreparably lost.
Unfortunately, given the nature of the repairs and upgradesneeded on each road, when the construction company works on aparticular road, it is unusable in either direction. This couldcause a problem if it becomes impossible to travel between twotourist attractions, even if the construction company works on onlyone road at any particular time.
So, the Road Department of Remote Island has decided to callupon your consulting services to help remedy this problem. It hasbeen decided that new roads will have to be built between thevarious attractions in such a way that in the final configuration,if any one road is undergoing construction, it would still bepossible to travel between any two tourist attractions using theremaining roads. Your task is to find the minimum number of newroads necessary.
Input
The first line of input will consist of positive integersn and r, separated by a space, where 3 ≤ n ≤1000 is the number of tourist attractions on the island, and 2 ≤r ≤ 1000 is the number of roads. The tourist attractions areconveniently labelled from 1 to n. Each of the followingr lines will consist of two integers, v and w,separated by a space, indicating that a road exists between theattractions labelled v and w. Note that you maytravel in either direction down each road, and any pair of touristattractions will have at most one road directly between them. Also,you are assured that in the current configuration, it is possibleto travel between any two tourist attractions.
Output
One line, consisting of an integer, which gives the minimumnumber of roads that we need to add.
Sample Input
Sample Input 1
10 12
1 2
1 3
1 4
2 5
2 6
5 6
3 7
3 8
7 8
4 9
4 10
9 10
Sample Input 2
3 3
1 2
2 3
1 3
Sample Output
Output for Sample Input 1
2
Output for Sample Input 2
0
题意: 道路修建, 要求添加最少的道路, 使得在整个无向图图中, 当其中一条边断开之后,
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 1005
struct node
{
}edges[MAX*3];
int n, m;
int first[MAX], num;
int stack[MAX], top, low[MAX], dfn[MAX], count;
int degree[MAX], bcc[MAX];
bool vis[MAX];
inline int min(int a, int b)
{
}
inline void add(int u, int v)
{
}
void readGraph()
{
}
void tarjan(int u, int fa, int deep)
{
}
int solve()
{
}
int main()
{
//
}
- ACM: 图论题 poj 3352 双连通题
- ACM: 图论题 poj 3177 同 3352
- ACM: 图论题 poj 2240 (floyd + ST…
- ACM: 图论题 poj 1135
- ACM: 图论题 poj 3…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 1275 差分约束题
- ACM: 二分法 数论题 poj 1905
- ACM: 匈牙利算法 图论题 poj 3041 …
- ACM: 差分约束 图论题 poj 2983 sp…
- ACM: 有向欧拉图 图论题 poj 1386 …
- ACM: poj 第50题 一题递推数论题 …
- ACM: 图论题 poj 2253 (poj上的dou…
- ACM: polay定理 数论题 poj 1286 …
- ACM: 二分图最佳匹配 图论题 poj 3…
- ACM: 二分图最大匹配 图论题 poj 2…
- ACM: 图论题 poj 1161 (把图重建成…
- 兴趣学习: opencv 实现画图程序
- ACM: 图论题 poj 3…
- ACM: 动态规划题 poj&nb…
- ACM: 博弈题 poj 1143 状态压缩
- ACM: 图论题 poj 2186 强连通分量
- ACM: 图论题 poj 3352 双连通题
- ACM: 图论题 poj 3177 同 3352
- Android的自定义控件起步
- dos批处理中%~dp0%的说明
- ACM: 图论题 poj 3308 最大流问题
- ACM: 搜索题 poj 1020
- ACM: 图论题 poj 1201 差分约束
- ACM: 图论题 poj 1149 网络流问题
- ACM: 图论题 poj 1236 强连通