Source code for submission s612

Go to diff to previous submission

Main.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package fn;
  6.  
  7. import java.io.BufferedReader;
  8. import java.io.InputStreamReader;
  9. import java.util.ArrayList;
  10. import java.util.Scanner;
  11.  
  12. /**
  13.  *
  14.  * @author kuric10
  15.  */
  16. public class Main {
  17.  
  18. /**
  19.   * @param args the command line arguments
  20.   */
  21. public static void main(String[] args) throws Exception {
  22. // TODO code application logic here
  23. // BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  24. // String s=input.readLine();
  25. // String pole[];
  26. int poc[] = new int[10001];
  27. //int spoje[][]
  28. int max;
  29. int prve;
  30. int druhe;
  31. int links;
  32. /* while(1==1){
  33.   prve=input.read();
  34.   input.read();
  35.   druhe=input.read();
  36.   input.read();
  37.   }*/
  38.  
  39. /* while(!s.equals(null)){
  40.   pole=s.split(" ");
  41.   max=Integer.parseInt(pole[0]);//nebol bz lepsi scanner ??
  42.   links=Integer.parseInt(pole[1]);
  43.   for (int i = 0; i < links; i++) {
  44.   s=input.readLine();
  45.   pole
  46.   }
  47.  
  48.   s=input.readLine();
  49.   }*/
  50. Scanner in = new Scanner(System.in);
  51. // ArrayList<int[]> a = new ArrayList<int[]>();
  52. int[] pomPole;
  53. int pom;
  54. boolean b;
  55. while (in.hasNextInt()) {
  56. b = false;
  57. max = in.nextInt();
  58. links = in.nextInt();
  59. // System.out.println(links);
  60. for (int i = 0; i < links; i++) {
  61. prve = in.nextInt();
  62. druhe = in.nextInt();
  63. if (prve > druhe) {
  64. pom = prve;
  65. prve = druhe;
  66. druhe = pom;
  67. }
  68. pomPole = new int[2];
  69. pomPole[0] = prve;
  70. pomPole[1] = druhe;
  71. //
  72. // if (!a.contains(i)) {
  73. poc[prve]++;
  74. poc[druhe]++;
  75. // a.add(pomPole);
  76. if (poc[prve] == 4 || poc[druhe] == 4) {
  77. b = true;
  78. //break;
  79. }
  80. // }
  81. }
  82. if (b) {
  83. System.out.println("YES");
  84. } else {
  85. System.out.println("NO");
  86. }
  87. for (int i = 0; i < max + 1; i++) {
  88. poc[i] = 0;
  89. }
  90. // a.clear();
  91.  
  92. }
  93. }
  94. }
  95.  

Diff to submission s604

Main.java

--- c5.s604.cteam085.fn.java.0.Main.java
+++ c5.s612.cteam085.fn.java.0.Main.java
@@ -21,7 +21,7 @@
     public static void main(String[] args) throws Exception {
         // TODO code application logic here
-        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
+    //    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
         // String s=input.readLine();
-        String pole[];
+  //      String pole[];
         int poc[] = new int[10001];
         //int spoje[][]
@@ -49,5 +49,5 @@
          }*/
         Scanner in = new Scanner(System.in);
-        ArrayList<int[]> a = new ArrayList<int[]>();
+     //   ArrayList<int[]> a = new ArrayList<int[]>();
         int[] pomPole;
         int pom;
@@ -70,13 +70,13 @@
                 pomPole[1] = druhe;
                 //
-                if (!a.contains(i)) {
+            //    if (!a.contains(i)) {
                     poc[prve]++;
                     poc[druhe]++;
-                    a.add(pomPole);
+                  //  a.add(pomPole);
                     if (poc[prve] == 4 || poc[druhe] == 4) {
                         b = true;
                         //break;
                     }
-                }
+             //   }
             }
             if (b) {
@@ -88,5 +88,5 @@
                 poc[i] = 0;
             }
-            a.clear();
+           // a.clear();
 
         }