hiho Week 11 register

Ended

Participants:433

Verdict:Accepted
Score:100 / 100
Submitted:2014-09-16 19:55: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 <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
const int N = 100003;
bool used[N];
vector<int> cmap[N];
int max_high, max_root;
int high[N];
int n;
void dfs(int root, int cur_high){
    used[root] = true;
    if(cur_high > max_high){
        max_high = cur_high;
        max_root = root;
    }
    for(vector<int>::iterator ite = cmap[root].begin(); ite != cmap[root].end(); ++ite){
        if(!used[*ite]){
            used[*ite] = true;
            dfs(*ite, cur_high + 1);
        }
    }
}
int main(){
    while(~scanf("%d", &n)){
        for(int i = 0; i < n - 1; i++){
            int from, to;
            scanf("%d%d", &from, &to);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX