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;
typedef long long ll;
vector<ll> lnk;
ll find(ll a) {
if (lnk[a] != a) lnk[a] = find(lnk[a]);
return lnk[a];
}
bool same(ll a, ll b) {
return find(a) == find(b);
}
void unite(ll a, ll b) {
a = find(a); b = find(b);
lnk[a] = b;
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
int m = u.size();
for (int i0 = 0; i0 < m; i0++) {
for (int i1 = i0+1; i1 < m; i1++) {
for (int i2 = i1+1; i2 < m; i2++) {
for (int i3 = i2+1; i3 < m; i3++) {
for (int i4 = i3+1; i4 < m; i4++) {
for (int i5 = i4+1; i5 < m; i5++) {
lnk = vector<ll>(n);
for (int i = 0; i < n; i++) lnk[i] = i;
if (same(u[i0], v[i0])) continue;
unite(u[i0], v[i0]);
if (same(u[i1], v[i1])) continue;
unite(u[i1], v[i1]);
if (same(u[i2], v[i2])) continue;
unite(u[i2], v[i2]);
if (same(u[i3], v[i3])) continue;
unite(u[i3], v[i3]);
if (same(u[i4], v[i4])) continue;
unite(u[i4], v[i4]);
if (same(u[i5], v[i5])) continue;
unite(u[i5], v[i5]);
if (count_common_roads({i0, i1, i2, i3, i4, i5}) == n-1) {
return {i0, i1, i2, i3, i4, i5};
}
}
}
}
}
}
}
return {};
}
# | 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... |