Lang:Java
Edit12345678910111213141516171819202122232425262728293031/****/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 = 1; i < nodes.length; i++) {nodes[i] = new Node();}for (int i = 0; i < N - 1; i++) {int a = scanner.nextInt();int b = scanner.nextInt();Node parent = nodes[a];Node child = nodes[b];