Go to diff to previous submission
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.regex.Pattern; public class fq { Pattern p = Pattern.compile("\\s"); String line; while ((line = buf.readLine()) != null) { int[] vstup = new int[line.length()]; for (int i = 0; i < line.length(); i++) { if (line.charAt(i) == '.') { vstup[i] = 0; } else if (line.charAt(i) == '(') { vstup[i] = 1; } else { vstup[i] = 2; } } //System.out.println("vstup: " + Arrays.toString(vstup)); int length = vstup.length; int[][] pole = new int[length + 1][length + 1]; for (int i = 1; i < pole.length; i++) { pole[i][0] = 1; } int milion = 100000; int pocetNaisto10 = 0; for (int x = 1; x < pole.length; x++) { int vstupPismeno = vstup[x - 1]; if (vstupPismeno == 2) { pocetNaisto10++; } if (pocetNaisto10 > 0) { pole[x][0] = 0; } for (int y = 1; y <= x; y++) { if (vstupPismeno == 0) { // bodka pole[x][y] = (pole[x - 1][y] + pole[x - 1][y - 1]) % milion; } if (vstupPismeno == 1) { // lava 5 ka pole[x][y] = (pole[x - 1][y]) % milion; } if (vstupPismeno == 2) { // prava 10 ka pole[x][y] = (pole[x - 1][y - 1]) % milion; } if (y > (x / 2)) { // if(pole[x][y]==0){break label1;} pole[x][y] = 0; } if (pocetNaisto10 > y+1) { pole[x][y]=0; } } } // for (int x = 0; x < pole.length; x++) { // System.out.print(x + " "); // } // System.out.println(); // System.out.println(); // // for (int y = 0; y < pole.length; y++) { // // for (int x = 0; x < pole.length; x++) { // // System.out.print(pole[x][y] + " "); // } // System.out.println(); // } // System.out.println((length-1)); } } }
--- c5.s1097.cteam096.fq.java.0.fq.java +++ c5.s1123.cteam096.fq.java.0.fq.java @@ -71,5 +71,5 @@ // System.out.println(); // System.out.println(); - +// // for (int y = 0; y < pole.length; y++) { // @@ -80,6 +80,6 @@ // System.out.println(); // } - - System.out.println(pole[length - 1][(length - 1) / 2]); +// System.out.println((length-1)); + System.out.println(pole[length][(length) / 2]); }