#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int M = 1e4+5, K = 4e2+2, MOD = 1e9+7;
vector<int> node[M];
int dist[M];
bitset<10005> vis;
void dfs(int s, int p = 0) {
if (!p) p = s, vis = 0, dist[s] = 0;
dist[s] = dist[p] + 1;
vis[s] = true;
for (int i:node[s])
if (!vis[i]) dfs(i, s);
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int a, b;
cin >> a >> b;
node[a].push_back(b);
node[b].push_back(a);
}
int ans = 0;
for (int i = 1; i <= n; i++) {
dfs(i);
for (int j = i+1; j <= n; j++) {
ans += dist[j]-2;
}
} cout << ans << endl;
return 0;
}
/*
1 2 3 4 5 6 7 8
1 2 2 4 5 6 7 8
3
SRS RR SRRRS RRRR
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
------
2 1 3
1 1 1 4
1 1 2 5
1 3
1 5
1 7
------
1 1 1
100000000 1 1 1
1 1
------
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |