MSBOP 2015 Round3 register

Ended

Participants:978

Verdict:AC | AC
Submitted:2015-05-09 14:39:24

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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 100010
int n, r;
long long w[N], sum[N], ans;
struct edge{
    int v;
    int next;
}e[N << 1];
int pre[N], ecnt;
void init() {
    ecnt = 0;
    memset(pre, -1, sizeof(pre));
}
void addEdge(int u, int v) {
    e[ecnt].v = v;
    e[ecnt].next = pre[u];
    pre[u] = ecnt++;
}
void dfs(int u, int p) {
    sum[u] = w[u];
    for (int i = pre[u]; i != -1; i = e[i].next) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX