Submission #516886

#TimeUsernameProblemLanguageResultExecution timeMemory
516886pragmatistDuathlon (APIO18_duathlon)C++17
5 / 100
1083 ms15196 KiB
#include <bits/stdc++.h> #define sz(v) v.size() #define pb push_back #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define x first #define y second #define int long long #define nl "\n" using namespace std; typedef long long ll; typedef pair<long long, long long> pll; typedef pair <ll, ll> pii; const int N = (int)3e5 + 7; const int M = (int)15e6 + 7; const ll MOD = (ll)1e9 + 7; const int inf = (ll)1e9 + 7; const ll INF = (ll)3e18 + 7; pii dir[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; int n, m, s, c, f; bool used[N]; vector<int> g[N]; bool dfs(int v, bool was) { used[v] = 1; if(v == c) was = 1; if(was && v == f) return 1; bool ok = 0; for(auto to : g[v]) { if(!used[to]) { ok |= dfs(to, was); if(ok) break; } } used[v] = 0; return ok; } void solve() { cin >> n >> m; for(int i = 1; i <= m; ++i) { int u, v; cin >> u >> v; g[u].pb(v); g[v].pb(u); } int ans = 0; for(s = 1; s <= n; ++s) { for(c = 1; c <= n; ++c) { for(f = 1; f <= n; ++f) { if(s != c && c != f && s != f) { fill(used + 1, used + 1 + n, 0); ans += dfs(s, 0); } } } } cout << ans << nl; } signed main() { ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); int test = 1; //cin >> test; for(int i = 1; i <= test; ++i) { //cout << "Case " << i << ": "; solve(); } return 0; } /* 4 3 1 2 2 3 3 4 */
#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...