Submission #586481

#TimeUsernameProblemLanguageResultExecution timeMemory
586481VanillaSimurgh (IOI17_simurgh)C++17
13 / 100
44 ms568 KiB
#include <bits/stdc++.h> #include "simurgh.h" using namespace std; const int maxn = 7; vector<int> find_roads(int n, vector<int> u, vector<int> v) { vector <int> r (n - 1, 0); int m = u.size(); auto check = [&] (vector <int> idx) { vector <vector <int> > ad(maxn); for (int i: idx) { ad[u[i]].push_back(v[i]); ad[v[i]].push_back(u[i]); } bitset <maxn> vis = 0; auto dfs = [&] (int u, auto&& dfs) -> void { vis[u] = 1; for (int v: ad[u]) { if (!vis[v]) dfs(v, dfs); } return; }; dfs(0, dfs); for (int i = 0; i < n; i++){ if (!vis[i]) return; } if (count_common_roads(idx) == n - 1) r = idx; }; auto back = [&] (int step, int pos, vector <int> &used, auto&& back) -> void { if (step == n - 1) { vector <int> idx; for (int i = 0; i < m; i++){ if (used[i]) idx.push_back(i); } check(idx); return; } for (int i = pos + 1; i < m; i++){ if (!used[i]) { used[i] = 1; back(step + 1, i, used, back); used[i] = 0; } } return; }; back(0, -1, *(new vector <int> (m, 0)), back); return r; }
#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...