题目大意:给出一个连通图,求再一个边后,剩余的最少桥数。
题目思路:首先进行缩点得到重构后的图,求出重构后树的直径(通过两次BFS求出相距最远的两点间的距离),ans=重构图边数-树的直径
//#pragma comment(linker, "/STACK:102400000,102400000")#include#include #include #include #include #include #include #include #define MAXSIZE 200005#define LL long longusing namespace std;vector >G;vector >G2;int vis[MAXSIZE],low[MAXSIZE],dfn[MAXSIZE],pre[MAXSIZE],k,Time,n,m,ans,link;int dist[MAXSIZE],belong[MAXSIZE],step[MAXSIZE],Stuck[MAXSIZE],block;void Tarjan(int u,int fa){ low[u]=dfn[u]=++Time; pre[u]=fa; Stuck[k++]=u; int v,len=G[u].size(),op=0; for(int i=0;i