Go to diff to previous submission
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package fr; import java.util.ArrayList; import java.util.Scanner; /** * * @author kuric10 */ @SuppressWarnings({"unchecked"}) public class Main { private static int hlavna, poc; private static ArrayList<int[]>[] pole; private static boolean[] pouzite; String s; int a, b; int[] pomPole; int kde; int pomi; while (input.hasNextLine()) { s = input.nextLine(); pom = s.split(" "); pouzite = new boolean[poc]; for (int i = 0; i < poc; i++) { pole[i] = new ArrayList<>(); } for (int i = 0; i < poc - 1; i++) { pomPole = new int[2]; s = input.nextLine(); pom = s.split(" "); pomPole[0] = a; pomPole[1] = b; pole[kde].add(pomPole); pomPole = new int[2]; pomPole[0] = kde; pomPole[1] = b; pole[a].add(pomPole); } } } private static int rek(int ja, int i) { pouzite[ja] = true; int sucet = 0; for (int[] is : pole[ja]) { if (pouzite[is[0]]) { continue; } sucet += rek(is[0], is[1]); } if (sucet == 0) { return i; } } }