#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
constexpr int M=2e5+7;
vector<pair<int,int> >g[M];
int k1, k2, k3;
bool o[M];
void dfs(int v){
o[v] = 1;
for(auto w:g[v]) if(!o[w.first] && w.second!=k1 && w.second!=k2 && w.second!=k3) dfs(w.first);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, a, b;
long long res=0;
cin >> n >> m;
for(int i=0; i<m; i++){
cin >> a >> b;
g[a].push_back({b,i});
g[b].push_back({a,i});
}
for(int i=0; i<m; i++){
for(int j=i+1; j<m; j++){
for(int k=j+1; k<m; k++){
k1 = i;
k2 = j;
k3 = k;
dfs(1);
for(int w=1; w<=n; w++){
if(!o[w]){
res++;
break;
}
}
for(int w=1; w<=n; w++) o[w]=0;
}
}
}
cout << res;
return 0;
}
/*
8 11
2 3
4 5
3 1
3 2
5 7
3 6
1 2
3 4
6 5
8 7
7 8
*/
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; constexpr int M=2e5+7; vector<pair<int,int> >g[M]; int k1, k2, k3; bool o[M]; void dfs(int v){ o[v] = 1; for(auto w:g[v]) if(!o[w.first] && w.second!=k1 && w.second!=k2 && w.second!=k3) dfs(w.first); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, a, b; long long res=0; cin >> n >> m; for(int i=0; i<m; i++){ cin >> a >> b; g[a].push_back({b,i}); g[b].push_back({a,i}); } for(int i=0; i<m; i++){ for(int j=i+1; j<m; j++){ for(int k=j+1; k<m; k++){ k1 = i; k2 = j; k3 = k; dfs(1); for(int w=1; w<=n; w++){ if(!o[w]){ res++; break; } } for(int w=1; w<=n; w++) o[w]=0; } } } cout << res; return 0; } /* 8 11 2 3 4 5 3 1 3 2 5 7 3 6 1 2 3 4 6 5 8 7 7 8 */ |
English