hihoCoder Challenge 14 register

Ended

Participants:709

Verdict:Accepted
Submitted:2015-08-30 19:29: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 <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <vector>
#define INF 0x3f3f3f3f
using namespace std;
int n, ans;
vector<int>mps[100010];
int dfs(int u, int fa, int d) {
    if(mps[u].size() == 1) return d;
    int x = 0, y = 0;
    for (int i = 0; i < mps[u].size(); i++) {
        int v = mps[u][i];
        if (v == fa) continue;
        int tmp = dfs(v, u, d + 1);
        if (tmp > y) {
            if (tmp > x) {
                y = x;
                x = tmp;
            }
            else {
                y = tmp;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX