# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
584482 | PiejanVDC | Simurgh (IOI17_simurgh) | C++17 | 3086 ms | 304 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;
int count_common_roads(const vector<int>& r);
vector<int>par;
int UF(int u) {
if(par[u] == u)
return u;
return par[u] = UF(par[u]);
}
vector<int> find_roads(int n, vector<int>u, vector<int>v) {
int m = u.size();
par.resize(n);
auto P = [&] () {
for(int i = 0 ; i < n ; i++)
par[i] = i;
};
auto splay = [&] (int a) {
vector<int>ret;
for(int i = 0 ; i < m ; i++) {
if(a & (1 << i))
ret.push_back(i);
}
return ret;
};
auto tree = [&] (vector<int>a) {
P();
if((int)a.size() != n-1)
return 0;
for(auto z : a) {
int A = UF(u[z]), B = UF(v[z]);
if(A == B)
return 0;
par[A] = B;
}
return 1;
};
for(int mask = 0 ; mask < (1 << m) ; mask++) {
if(tree(splay(mask))) {
vector<int>ask = splay(mask);
int x = count_common_roads(ask);
if(x == n-1) {
return ask;
}
}
}
}
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... |