hiho Week 11 register

Ended

Participants:433

Verdict:Accepted
Score:100 / 100
Submitted:2014-09-19 23:52:47

Lang:GCC

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>
#define N (100000)
struct edge {
    int nid;
    struct edge *next;
};
struct edge *nodes[N];
struct edge edges[N << 1];
struct edge *stack[N];
int stack_max[N][2];
int used[N];
void add_edge(int src, int to, int eid)
{
    edges[eid].nid = to;
    edges[eid].next = nodes[src];
    nodes[src] = &edges[eid];
}
int main()
{
    int n, i, a, b, nedge, top, len, max_path;
    scanf("%d", &n);
    for(i = 1, nedge = 0; i < n; i++) {
        scanf("%d%d", &a, &b);
        add_edge(--a, --b, nedge++);
        add_edge(b, a, nedge++);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX