#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int N = 1e5+3;
vector<int> grf[N], tree[N];
int pre[N], low[N], cnt;
ll spj[N], DP[N][3];
bool odw[N], art[N];
void dfs(int v, int p){
odw[v]=1;
pre[v]=low[v]=cnt; cnt++;
int chldr=0;
for(auto w:grf[v]){
if(w==p) continue;
if(odw[w]) low[v]=min(low[v], pre[w]);
else{
dfs(w, v);
chldr++;
low[v]=min(low[v], low[w]);
if(low[w] >= pre[v] && v!=1 ) art[v]=1;
}
}
if(v==1 && chldr>1) art[v]=1;
}
void makeTree(int v, int p){
odw[v]=1;
for(auto w:grf[v]){
if(odw[w]) continue;
if(art[v]) makeTree(w, v);
else makeTree(w, p);
}
}
void dfsDP(int v, int p){
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
for(int i=0; i<m; i++){
int a, b;
cin >> a >> b;
grf[a].pb(b);
grf[b].pb(a);
}
dfs(1, 1);
for(int i=1; i<=n; i++) spj[low[i]]++;
ll out=0;
for(int i=0; i<=n; i++) out+=((spj[i]-2)*spj[i]*(spj[i]-1));
cout << out << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |