CF - Ostap & Tree

Author: Benjamin Qi

Table of Contents


Edit on Github

Solution described by editorial is terrible, but we can do better! This runs in O(NK)O(NK) time. (proof?)

vmi yes[MX], no[MX];
vi adj[MX];
int n,k;
void dfs(int x, int y) {
yes[x] = no[x] = {1}; // black, not black
// dist of closest good vertex
// or dist of farthest bad vertex
auto ad = [](vmi& a, int b, mi c) {
while (sz(a) <= b) a.pb(0);

Give Us Feedback on CF - Ostap & Tree!