Topic Link:
Click to open the link
The main effect of the topic:
Give a picture, ask at least how many edges, turn him into a side-connected graph
Topic Analysis:
First, the point of double connected graph is reduced, (the point-connected graph must be a side-connected graph), then get a tree, for a tree, we just need to know how many points at the bottom of the tree, and then connect them 22, then all the points have at least two paths to reach, because the tree's two chain connected to become a ring, The loop is the path point has two paths to arrive, and then very easy to get the results, shrink point what is already a template
The code is as follows:
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <
vector> #include <map> #include <stack> #define MAX 1007 using namespace std;
int n,m,u,v;
int dfn[max],low[max],b[max],times,cnt;
int In[max];
typedef pair<int,int> PII;
Stack<int> s;
Vector<int> E[max];
Map<pii,bool> MP;
void Tarjan (int u, int p) {Dfn[u] = low[u] = ++times;
S.push (U);
int len = E[u].size ();
for (int i = 0; i < len; i++) {int v = e[u][i];
if (v = = p) continue;
if (!dfn[v]) {Tarjan (V, u);
Low[u] = min (Low[u], low[v]);
else Low[u] = min (Low[u], dfn[v]);
} if (low[u] = = Dfn[u]) {int temp;
do {temp = S.top ();
B[TEMP] = cnt;
S.pop ();
}while (temp!= u);
cnt++;
} void Init () { for (int i = 0; i < MAX; i++) e[i].clear ();
while (!s.empty ()) S.pop ();
Times = CNT = 0;
Mp.clear ();
memset (in, 0, sizeof (in));
int main () {while (~scanf ("%d%d", &n, &m)) {init ();
while (m--) {scanf ("%d%d", &u, &v);
E[u].push_back (v);
E[v].push_back (U);
for (int i = 1; I <= n; i++) if (!dfn[i]) Tarjan (i,-1);
for (int i = 1; I <= n; i++) {int len = e[i].size ();
for (int j = 0; J < Len; j +) {int v = e[i][j];
if (b[i] = = B[v]) continue;
if (Mp[make_pair (I,V)]) continue;
Mp[make_pair (i,v)] = true;
in[b[v]]++;
} int ans = 0;
for (int i = 0; i < cnt; i++) if (in[i] = = 1) ans++;
printf ("%d\n", (ans+1)/2);
}
}