UVA 796 Critical Links

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82833#problem/C

UVA链接地址

Root    

796 - Critical Links

Time limit: 3.000 seconds


题目大意:给你一个网络要求这里面的桥。
输入数据:
n 个点
点的编号  (与这个点相连的点的个数m)  依次是m个点的

输入到文件结束。
桥输出的时候需要排序

知识汇总:
桥:   无向连通图中,如果删除某条边后,图变成不连通了,则该边为桥。
求桥:
在求割点的基础上吗,假如一个边没有重边(重边 1-2, 1->2 有两次,那么 1->2 就是有两条边了,那么 1->2就不算是桥了)。
当且仅当 (u,v) 为父子边,且满足 dfn[u] < low[v]

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

#define N 12005
#define INF 0xfffffff
#define PI acos (-1.0)
#define EPS 1e-8

struct node
{
    int x, y;
    bool friend operator < (node a, node b)
    {
        if (a.x == a.y) return a.y < b.y;
        return a.x < b.x;
    }
}bridge[N];

vector  G[N];
int n, low[N], dfn[N], f[N], Time, ans;

void Init ();
void solve ();
void tarjan (int u, int fa);

int main ()
{
    while (~scanf ("%d", &n))
    {
        Init ();
        for (int i=0; i bridge[ans].y)
                swap (bridge[ans].x, bridge[ans].y);
            ans++;
        }
    }

    sort (bridge, bridge+ans);

    printf ("%d critical links\n", ans);
    for (int i=0; i


你可能感兴趣的:(连通图)