제출 #432110

#제출 시각아이디문제언어결과실행 시간메모리
432110SuhaibSawalha1철인 이종 경기 (APIO18_duathlon)C++17
5 / 100
1098 ms13632 KiB
#include <bits/stdc++.h> using namespace std; int n, m, nodes, vid, found; vector<vector<int>> adj; vector<int> vis; long long ans; void dfs (int u, int t, int k, bool ok = 0) { if (found) { return; } vis[u] = vid; if (u == k) { found = ok; ans += ok; } ok |= u == t; for (int v : adj[u]) { if (vis[v] != vid) { dfs(v, t, k, ok); } } vis[u] = 0; } int main (){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; adj.resize(n); while (m--) { int u, v; cin >> u >> v, --u, --v; adj[u].push_back(v); adj[v].push_back(u); } vis.resize(n); for (int u = 0; u < n; ++u) { for (int v = 0; v < n; ++v) { for (int k = 0; k < n; ++k) { if (set<int>{u, v, k}.size() == 3) { ++vid; found = 0; dfs(u, v, k); } } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...