# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422982 | albertolg101 | Simurgh (IOI17_simurgh) | C++17 | 1 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;
using pii = pair<int, int>;
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
vector<vector<int>> g(n, vector<int> (n));
for(int i = 0 ; i < n ; i++)
{
int a = u[i], b = v[i];
g[a][b] = g[b][a] = i;
}
int nextNod = 0;
vector<int> vans, perm(n);
for(int i = 0 ; i < n ; i++)
perm[i] = i;
function<void(int)> dfs = [&](int nod)
{
nextNod++;
while(nextNod < perm.size() and g[nod][perm[nextNod]] != -1)
{
vans.push_back(g[nod][perm[nextNod]]);
dfs(perm[nextNod]);
}
};
do
{
vans.clear();
nextNod = 0;
dfs(perm[0]);
if(count_common_roads(vans) == n - 1)
return vans;
} while(next_permutation(perm.begin(), perm.end()));
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |