Submission #516860

#TimeUsernameProblemLanguageResultExecution timeMemory
516860shmadDuathlon (APIO18_duathlon)C++17
5 / 100
1 ms460 KiB
#pragma GCC optimize("O3", "unroll-loops") #pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt") #include <bits/stdc++.h> #define int long long #define vt vector #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() #define ff first #define ss second #define dbg(x) cerr << #x << " = " << x << '\n' using namespace std; using ll = long long; using pii = pair<int, int>; using vvi = vt< vt<int> >; const int N = 1e6 + 5, mod = 1e9 + 7, inf = 1e18 + 7, B = 500, LIM = (1ll << 60); const double eps = 1e-6; vt<int> g[20], used(20); bool ok; void dfs (int v, int s, int c, int f, bool check = 0) { used[v] = 1; if (v == f) { ok |= check; return; } if (ok) return; if (v == c) check = 1; for (auto to: g[v]) { if (!used[to]) { dfs(to, s, c, f, check); used[to] = 0; } } } void solve () { int n, m; cin >> n >> m; for (int i = 1; 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++) { for (int k = 1; k <= n; k++) { if (i == j || i == k || j == k) continue; ok = 0; fill(all(used), 0); dfs(i, i, j, k); if (ok) ans++; } } } cout << ans; cout << '\n'; } bool testcases = 0; signed main() { cin.tie(0) -> sync_with_stdio(0); int test = 1; if (testcases) cin >> test; for (int cs = 1; cs <= test; cs++) { solve(); } }
#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...