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 "split.h"
#include <bits/stdc++.h>
using namespace std;
using i32 = int;
#define int long long
#define len(x) (int)(x.size())
#define inf 1000'000'000'000'000'000LL
#define all(x) x.begin(), x.end()
#define low_bit(x) (x & (-x))
template<typename T>
using vec = vector<T>;
vector<i32> find_split(i32 n, i32 a, i32 b, i32 c, vector<i32> p, vector<i32> q) {
vec<vec<int>> g(n);
for (int i = 0; i < len(p); i++) {
g[p[i]].push_back(q[i]);
g[q[i]].push_back(p[i]);
}
vec<i32> ans(n, -1);
vec<int> sizes(n);
int need = 0;
int T = 0;
vec<bool> used(n, false);
function<void(int, int)> choose = [&](int v, int p) {
if (need == 0)
return;
if (used[v]) return;
used[v] = true;
need--;
ans[v] = T;
for (auto u: g[v]) {
if (u == p) continue;
choose(u, v);
}
};
need = b;
T = 2;
choose(0, -1);
for (int i = 0; i < n; i++) {
if (ans[i] == -1) {
ans[i] = 1;
break;
}
}
for (int i = 0; i < n; i++) {
if (ans[i] == -1) {
ans[i] = 3;
break;
}
}
return ans;
}
# | 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... |