hiho week 312 register

Ended

Participants:33

Verdict:Accepted
Score:100 / 100
Submitted:2020-06-21 18:20:41

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;
struct node{
    int n;
    struct node* next;
    node(int x, struct node* y) {
        n=x;
        next=y;
    };
    node() {
        n=0;
        next=NULL;
    }
}tree[100010];
int N,res;
int walk(int x,int fa){
    int i,k,nn=1;
    struct node* temp=tree[x].next;
    while(temp!=NULL) {
        if(temp->n!=fa){
            k=walk(temp->n,x);
            if(k%2==0)res++;
            nn+=k;
        }
        temp=temp->next; 
    }
    return nn;
}
int main()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX