java:只过了 10%,可以帮我看看为什么吗?
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int n = in.nextInt(); // 已有的节点个数
int k = in.nextInt(); // 距离
int[] degrees = new int[n]; // 出度
List<Integer>[] children = new ArrayList[n];
for (int i = 0; i < n; i++) {
children[i] = new ArrayList<>();
}
for (int i = 0; i < n - 1; i++) {
int u = in.nextInt() - 1;
int v = in.nextInt() - 1;
degrees[u]++;
degrees[v]++;
children[u].add(v);
children[v].add(u);
}