hiho week 64 register

Ended

Participants:874

Verdict:Wrong Answer
Score:40 / 100
Submitted:2015-09-19 22:37:23

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 <map>
#include <list>
#include <memory>
#include <cstring>
using namespace std;
vector< vector<int> > tree;
vector< vector< pair<int,int> > > section;
vector<int> height;
void dfs(int root){
    if(tree[root].empty()) return;
    int sectionStart = 0;
    int tempSection = 0;
    for(int i = 0;i<section[root].size(); i++){
        int num = section[root][i].first;
        int j = 0;
        while(num--){
            int child = tree[root][sectionStart + j];
            //cout<<child<<',';
            dfs(child);
            section[root][i].second=max(section[root][i].second, max(section[root][i].first,height[child]+j));
            j++;
        }
        sectionStart += j;
        
        height[root] = min(max(height[root]+section[root][i].first,section[root][i].second),max(height[root],section[root][i].second+tempSection));
        tempSection += section[root][i].first;
        //cout<<root<<",i="<<i<<",height[root]="<<height[root]<<",s[i]="<<section[root][i].first<<",h[i]"<<section[root][i].second<<endl;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX