hihoCoder Challenge 14 register

Ended

Participants:709

Verdict:Accepted
Submitted:2015-08-30 19:30:02

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 <cstring>
#include <algorithm>
#include <cctype>
#include <queue>
#define rep(i, l, r) for(int i=l; i<=r; i++)
#define down(i, l, r) for(int i=l; i>=r; i--)
#define clr(x, c) memset(x, c, sizeof(x))
#define travel(x) for(edge *p=fir[x]; p; p=p->n)
#define maxn 100009
#define maxm 100009
#define inf 0x7fffffff
#define ll long long
using namespace std;
int read()
{
    int x=0, f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)) x=x*10+ch-'0', ch=getchar();
    return x*f;
}
struct edge{int y; edge *n;} e[maxm], *fir[maxn], *pt=e;
void AddE(int x, int y){pt->y=y, pt->n=fir[x], fir[x]=pt++;}
int n, f[maxn], s[maxn], q[maxn];
void dfs(int x)
{
    travel(x) dfs(p->y);
    int tot=0; 
    travel(x) q[++tot]=f[p->y];
    sort(q+1, q+1+tot);
    if (tot>1) s[x]=q[tot]+q[tot-1]+2;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX