[Offer收割]编程练习赛19 register

Ended

Participants:405

Verdict:Time Limit Exceeded
Score:0 / 100
Submitted:2017-07-23 14:29:42

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;
const int maxn = 100005;
int n, m, K, fa[maxn][19];
int dep[maxn];
vector<int> g[maxn];
void dfs(int x, int f)
{
    fa[x][0] = f;
    dep[x] = dep[f]+1;
    for(vector<int>::iterator it = g[x].begin() ; it != g[x].end() ; ++it)
        if(*it != f)
            dfs(*it, x);
}
void init()
{
    scanf("%d %d", &n, &m);
    for(int i = 1 ; i < n ; ++i)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    memset(dep, 0, sizeof(dep));
    dfs(1, 1);
    for(int k = 1 ; (1<<k) < n ; ++k)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX