hiho week 291 register

Ended

Participants:37

Verdict:Accepted
Score:100 / 100
Submitted:2020-01-28 10:13:53

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "bits/stdc++.h"
using namespace std;
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<vector<int>> g(n + 1);
    for (int i = 1; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    vector<int> res(n + 1, 0);
    auto dfs = function<void(int, int)>();
    dfs = [&](int f, int u)
    {
        //cerr << "hi " << f << " " << u << "\n";
        res[u] = f;
        for (auto v : g[u])
        {
            if (v != f)
            {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX