hiho Week 12 register

Ended

Participants:337

Verdict:Accepted
Score:100 / 100
Submitted:2014-09-21 01:32:29

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;
int n, m;
int score[100];
int f[100][100+1];
vector<int> edge[100];
void getData() {
    cin >> n >> m;
    for (int i=0; i<n; i++) cin >> score[i];
    
    int lhs, rhs;
    edge[0].push_back(0);
    for (int i=0; i<n-1; i++) {
        cin >> lhs >> rhs;
        lhs--;
        rhs--;
        if (edge[lhs].size() == 0) swap(lhs, rhs);
        edge[lhs].push_back(rhs);
        edge[rhs].push_back(rhs);
    }
}
void calc(int root) {
    if (edge[root].size() == 1) {
        f[root][1] = score[root];
    } else {
        f[root][1] = score[root];
        for (int i=1; i<edge[root].size(); i++) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX