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

Ended

Participants:399

Verdict:Accepted
Score:100 / 100
Submitted:2017-09-03 13:03:16

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 <vector>
using namespace std;
typedef struct Node {
    int val;
    bool visited;
    vector<int> neighbors;
};
Node tree[200000];
int cnt = 0;
void dfs(int u) {
    tree[u].visited = true;
    for (int v : tree[u].neighbors) {
        if (!tree[v].visited) {
            dfs(v);
            tree[u].val += tree[v].val;
            if (tree[v].val % 2 == 0) {
                cnt++;
            }
        }
    }
}
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX