# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
217788 | 2020-03-30T18:36:00 Z | Vimmer | 철인 이종 경기 (APIO18_duathlon) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 300005 #define M ll(998244353) using namespace std; typedef long double ld; typedef long long ll; typedef short int si; vector <int> g[51]; bool mk[51]; vector <int> vr; set <int> se; void dostig(int v, int to) { if (mk[v]) return; if (v == to) { for (auto it : vr) se.insert(it); return; } mk[v] = 1; vr.pb(v); bool f = 0; for (auto it : g[v]) dostig(it, to); mk[v] = 0; vr.pop_back(); return f; } int main() { ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; g[x].pb(y); g[y].pb(x); } int ans = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { if (i == j) continue; se.clear(); dostig(i, j); if (sz(se) != 0) ans += sz(se) - 1; } cout << ans << endl; }