[Offer收割]编程练习赛25 register

Ended

Participants:399

Verdict:Accepted
Score:100 / 100
Submitted:2017-09-03 13:13:46

Lang:Java

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
/**
 * 
 */
import java.util.ArrayList;
import java.util.Scanner;
/**
 * @author zhongfang
 *
 */
public class Main {
    static class Node {
        ArrayList<Node> neibors = new ArrayList<>();
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Node nodes[] = new Node[N + 1];
        for (int i = 1i < nodes.lengthi++) {
            nodes[i= new Node();
        }
        for (int i = 0i < N - 1i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            Node parent = nodes[a];
            Node child = nodes[b];
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX