hiho Week 11 register

Ended

Participants:433

Verdict:Accepted
Score:100 / 100
Submitted:2014-09-13 21:24:19

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>
#define N 100002
struct node{
    int to,next;
}e[2*N];
int h[N];
bool vis[N];
int dist[N];
int p,ans;
void dfs(int v,int d){
    vis[v]=1;
    dist[v]=d;
    for(int i=h[v];i;i=e[i].next){
        int u=e[i].to;
        if(!vis[u]){
            dfs(u,d+1);
        }
    }
}
int ct;
void adde(int u,int v){
    e[ct].to=v;e[ct].next=h[u];
    h[u]=ct++;
    e[ct].to=u;e[ct].next=h[v];
    h[v]=ct++;
}
int main(){
    int n;
    scanf("%d",&n);
    ct=1;
    for(int i=1;i<n;i++){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX