# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
974436 | 2024-05-03T10:32:48 Z | vjudge1 | 철인 이종 경기 (APIO18_duathlon) | C++17 | 0 ms | 0 KB |
#pragma GCC optimize("O3,Ofast,unroll-loops") #include <bits/stdc++.h> #define lli long long int #define ld long double #define pb push_back #define MP make_pair #define REP(i, n) for(int i = 0; (i) < (n); (i)++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const int N = 55; const int INF = 1e9 + 500; int n, m; array<vector<int>, N> adj; array<int, N> vis inline bool dfs(int node, int l, int t) { if(l == node) return 0; if(node == t) return 1; vis[node] = 1; for(auto c : adj[node]) { if(vis[c]) continue; if(dfs(c, l, t)) { return 1; } } return 0; } void solve() { cin >> n >> m; REP(i, m) { int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } int ans = 0; for(int i = 1; i<=n; i++) { for(int j = 1; j <= n; j++) { for(int k = 1; k <= n; k++) { if(i == j || j == k || i == k) continue; bool f = 1; for(int l = 1; l <= n; l++) { if(l == j) continue; fill(vis.begin(), vis.begin() + n + 1, 0); bool x = 0; if(dfs(i, l, j)) x = 1; fill(vis.begin(), vis.begin() + n + 1, 0); if(dfs(k, l, j)) x = 1; if(!x) { f = 0; break; } } ans += f; } } } cout << ans << "\n"; } signed main() { fastio(); solve(); }