This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define printv(a, b) {bool pvs = false; \
for(auto i : a){ \
if(pvs) b << ' '; \
b << i; pvs = true; \
} \
b << '\n';}
using namespace std;
typedef long long ll;
const ll MAX = 2147483647;
vector<vector<int>> g;
vector<bool> tmp;
vector<bool> vst;
bool dfs(int now, int d){
vst[now] = true;
bool t = false;
for(int i : g[now]){
if(vst[i]) continue;
if(dfs(i, d)){
tmp[now] = true;
t = true;
}
}
vst[now] = false;
return t || now == d;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
g.resize(n + 1);
vst.resize(n + 1);
for(int i = 0; i < m; i++){
int u, v;
cin >> u >> v;
g[u].eb(v);
g[v].eb(u);
}
tmp.resize(n + 1);
ll ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(i == j) continue;
fill(tmp.begin(), tmp.end(), false);
dfs(i, j);
for(int k = 1; k <= n; k++){
if(k != i && k != j) ans += tmp[k];
}
}
}
cout << ans << "\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... |