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;
#define sz(x) (int)x.size()
#define pb push_back
#define loop(x, i) for (int i = 0; i < x; i++)
#define rev(x, i) for (int i = (int)x - 1; i >= 0; i--)
#define ALL(x) begin(x), end(x)
typedef signed i32;
typedef vector<i32> vi32;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
vi find_split(int n, int a, int b, int c, vi p, vi q)
{
vvi adj(n);
int m = sz(p);
loop(m, i)
{
adj[p[i]].pb(q[i]);
adj[q[i]].pb(p[i]);
}
vi res(n);
auto dfs = [&](auto &&dfs, int i, int prev, int cnt) -> void
{
if (cnt < a)
res[i] = 1;
else if (cnt < a + b)
res[i] = 2;
else
res[i] = 3;
for (int j : adj[i])
{
if (j == prev)
continue;
dfs(dfs, j, i, cnt + 1);
}
};
loop(n, i)
{
if (adj[i].size() == 1)
{
dfs(dfs, i, i, 0);
break;
}
}
return res;
}
# | 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... |