Source code for submission s1123

Go to diff to previous submission

fq.java

  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.Arrays;
  5. import java.util.regex.Pattern;
  6.  
  7. public class fq {
  8.  
  9. public static void main(String[] args) throws IOException {
  10. Pattern p = Pattern.compile("\\s");
  11. String line;
  12.  
  13. while ((line = buf.readLine()) != null) {
  14. int[] vstup = new int[line.length()];
  15. for (int i = 0; i < line.length(); i++) {
  16. if (line.charAt(i) == '.') {
  17. vstup[i] = 0;
  18. } else if (line.charAt(i) == '(') {
  19. vstup[i] = 1;
  20. } else {
  21. vstup[i] = 2;
  22. }
  23. }
  24. //System.out.println("vstup: " + Arrays.toString(vstup));
  25.  
  26. int length = vstup.length;
  27. int[][] pole = new int[length + 1][length + 1];
  28. for (int i = 1; i < pole.length; i++) {
  29. pole[i][0] = 1;
  30. }
  31.  
  32. int milion = 100000;
  33. int pocetNaisto10 = 0;
  34. for (int x = 1; x < pole.length; x++) {
  35. int vstupPismeno = vstup[x - 1];
  36. if (vstupPismeno == 2) {
  37. pocetNaisto10++;
  38. }
  39. if (pocetNaisto10 > 0) {
  40. pole[x][0] = 0;
  41. }
  42. for (int y = 1; y <= x; y++) {
  43. if (vstupPismeno == 0) {
  44. // bodka
  45. pole[x][y] = (pole[x - 1][y] + pole[x - 1][y - 1])
  46. % milion;
  47. }
  48. if (vstupPismeno == 1) {
  49. // lava 5 ka
  50. pole[x][y] = (pole[x - 1][y]) % milion;
  51. }
  52. if (vstupPismeno == 2) {
  53. // prava 10 ka
  54. pole[x][y] = (pole[x - 1][y - 1]) % milion;
  55. }
  56. if (y > (x / 2)) {
  57. // if(pole[x][y]==0){break label1;}
  58. pole[x][y] = 0;
  59.  
  60. }
  61. if (pocetNaisto10 > y+1) {
  62. pole[x][y]=0;
  63. }
  64. }
  65. }
  66. // for (int x = 0; x < pole.length; x++) {
  67. // System.out.print(x + " ");
  68. // }
  69. // System.out.println();
  70. // System.out.println();
  71. //
  72. // for (int y = 0; y < pole.length; y++) {
  73. //
  74. // for (int x = 0; x < pole.length; x++) {
  75. //
  76. // System.out.print(pole[x][y] + " ");
  77. // }
  78. // System.out.println();
  79. // }
  80. // System.out.println((length-1));
  81. System.out.println(pole[length][(length) / 2]);
  82.  
  83. }
  84.  
  85. }
  86. }
  87.  

Diff to submission s1097

fq.java

--- 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]);
 
                 }