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<iostream>
#include<vector>
using namespace std;
const int N = 2e5 + 123;
vector<int>g[N];
int A, B;
int used[N];
vector<int>vec;
void dfs(int v) {
vec.emplace_back(v);
used[v] = 1;
for (int to : g[v]) if (!used[to]) {
dfs(to);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int>ans(n);
for (int i = 0 ; i < n - 1 ; ++ i) {
g[p[i]].emplace_back(q[i]);
g[q[i]].emplace_back(p[i]);
}
if (a > b) swap(a, b);
if (b > c) swap(b, c);
if (a > b) swap(a, b);
A = a, B = b;
dfs(0);
for (int i = 0 ; i < a ; ++ i) ans[vec[i]] = 1;
for (int i = 0 ; i < b ; ++ i) ans[vec[i+a]] = 2;
for (int i = 0 ; i < c ; ++ i) ans[vec[i+a+b]] = 3;
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... |