hiho week 109 register

Ended

Participants:438

Verdict:Accepted
Score:100 / 100
Submitted:2016-08-06 03:54:05

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>
#include <algorithm>
using namespace std;
const int MAX_WALLET = 200000000;
class Node {
public:
    int p,q,pt,qt,vis;
    vector<int> sons;
    Node() {
        vis = 0;
    }
};
vector<Node> nodes;
void dfs(int rt) {
    nodes[rt].vis = 1;
    int wallet = MAX_WALLET;
    int minWallet = MAX_WALLET;
    vector<int> sons;
    for(int i : nodes[rt].sons) {
        if(nodes[i].vis) continue;
        dfs(i);
        sons.push_back(i);
    }
    sort(sons.begin(),sons.end(),[](int a,int b){
        return nodes[a].qt > nodes[b].qt;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX