hiho week 312 register

Ended

Participants:33

Verdict:Accepted
Score:100 / 100
Submitted:2020-06-21 19:27:59

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<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int N;
vector<int>tree[100010];
int ans,sa;
int dfs(int u,int v)
{
    int sum=0;
    sa=0;
    for(int i=0;i<tree[u].size();i++)
    {
        int x=tree[u][i];
        if(x!=v)
        {
            sa=dfs(x,u);
            sum+=sa;
        }
    }
    if(sum%2==1)ans++;
    return sum+1;
}
int main()
{
    cin>>N;
    int a,b;
    for(int i=1;i<N;i++)
    {
        cin>>a>>b;
        tree[a].push_back(b);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX