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

Ended

Participants:399

Verdict:Accepted
Score:100 / 100
Submitted:2017-09-03 14:09: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;
const int N = 100005;
int son[N];
vector <int> es[N];
void dfs(const int &u, const int &f) {
  son[u] = 1;
  for (int v : es[u]) {
    if (v == f)
      continue;
    dfs(v, u);
    son[u] += son[v];
  }
}
int main()
{
  int n, a, b;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d %d", &a, &b);
    es[a].push_back(b);
    es[b].push_back(a);
  }
  dfs(1, -1);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX