Go to diff to previous submission
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package fq; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; /** * * @author drevenak3 */ public class FQ { /** * @param args the command line arguments */ int n, u, v, hlavny; while (scan.hasNext()) { n = scan.nextInt(); hlavny = scan.nextInt(); int[][] pole = new int[n + 1][n + 1]; for (int i = 1; i <= n-1; i++) { u = scan.nextInt(); v = scan.nextInt(); int c=scan.nextInt(); pole[u][v] = c; pole[v][u] = c; } int e=0; for(int i=1;i<=n;++i){ if(pole[hlavny][i]!=0){ e+=enrgiaVetvy(pole,hlavny,i); } } } } public static int enrgiaVetvy(int [][]paPole,int paZ,int paDo){ int cestaPrisiel=paPole[paDo][paZ]; int cestaZ=0; for(int i=1;i<paPole.length;++i){ if(paPole[paDo][i]!=0&&i!=paZ){ cestaZ+=enrgiaVetvy(paPole,paDo,i); } } if(cestaZ==0){ return cestaPrisiel; } } }
--- c5.s981.cteam083.fr.java.0.FQ.java +++ c5.s987.cteam083.fr.java.0.FQ.java @@ -7,5 +7,4 @@ import java.io.File; import java.io.FileNotFoundException; -import java.util.ArrayList; import java.util.Scanner; @@ -21,7 +20,4 @@ public static void main(String[] args) { Scanner scan = new Scanner(System.in); - try{ - scan=new Scanner(new File("in.txt")); - }catch(FileNotFoundException e){} int n, u, v, hlavny; while (scan.hasNext()) { @@ -36,20 +32,4 @@ pole[v][u] = c; } - /*ArrayList<Integer> rh=new ArrayList<Integer>(); - ArrayList<Integer> rhw=new ArrayList<Integer>(); - for(int i=1;i<=n;++i){ - int st=0; - for(int j=1;j<i;++j){ - if(pole[i][j]!=0){ - ++st; - if(st>=2) break; - } - } - if(st==1){ - int min=0; - - rhw - } - }*/ int e=0; for(int i=1;i<=n;++i){