1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const int N = 100010, MOD = 1e9 + 7, INF = 0x3f3f3f3f;
int n, m, u, v, dfn[N], ti, fa[N], low[N], child[N], cnt;
vi g[N];
void tarjan(int u) {
low[u] = dfn[u] = ++ti;
for (auto v : g[u]) {
if (!dfn[v]) {
fa[v] = u;
tarjan(v);
low[u] = min(low[u], low[v]);
if (low[v] > dfn[u]) {
cnt++;
}
} else if (dfn[v] < dfn[u] && fa[u] != v) {
low[u] = min(low[u], dfn[v]);
}
}
}
int main() {
#ifndef ONLINE_JUDGE
freopen("data/in.txt", "r", stdin);
freopen("data/out.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
};
for (int i = 1; i <= n; i++)
if (!dfn[i]) tarjan(i);
cout << cnt;
return 0;
}
|