Source code for submission s894

Go to diff to previous submission

Fn.java

  1.  
  2. import java.util.ArrayList;
  3. import java.util.Scanner;
  4.  
  5.  
  6. /*
  7.  * To change this template, choose Tools | Templates
  8.  * and open the template in the editor.
  9.  */
  10.  
  11. /**
  12.  *
  13.  * @author kajanek6
  14.  */
  15. public class Fn {
  16.  
  17. /**
  18.   * @param args the command line arguments
  19.   */
  20. public static void main(String[] args) {
  21. // TODO code application logic here
  22. ArrayList<ArrayList<Integer>> zoznam = new ArrayList<ArrayList<Integer>>();
  23.  
  24. ArrayList<Integer> podZoznam;
  25. Scanner input = new Scanner(System.in);
  26. int n,m;
  27. int prvy,druhy;
  28. while (input.hasNextInt()) {
  29.  
  30. zoznam.clear();
  31. n=0;
  32. m=0;
  33. n = input.nextInt();
  34. m = input.nextInt();
  35. for(int i=0; i<=n;i++){
  36. zoznam.add(new ArrayList<Integer>());
  37. }
  38. for(int i=0;i<m;i++){
  39. prvy=input.nextInt();
  40. druhy=input.nextInt();
  41. podZoznam=zoznam.get(prvy);
  42. podZoznam.add(druhy);
  43. podZoznam=zoznam.get(druhy);
  44. podZoznam.add(prvy);
  45. }
  46. int k=0;
  47. for(ArrayList<Integer> ar:zoznam)
  48. {
  49. if(ar.size()==4){
  50. k=1;
  51. for(Integer i:ar){
  52. if(zoznam.get(n).size()!=1)
  53. {
  54. k=0;
  55. }
  56. }
  57. if(k==1)
  58. break;
  59. }
  60.  
  61. }
  62. if(k==1){
  63. System.out.printf("YES\n");
  64. }else{
  65. System.out.printf("NO\n");
  66. }
  67.  
  68.  
  69.  
  70. }
  71.  
  72. }
  73. }
  74.  

Diff to submission s875

Fn.java

--- c5.s875.cteam087.fn.java.0.Fn.java
+++ c5.s894.cteam087.fn.java.0.Fn.java
@@ -55,17 +55,17 @@
                     }
                 }
-                    
+                    if(k==1)
+                    break;
                 }
+                
             }
-            if(k==1)
-            {
-               System.out.printf("YES\n"); 
-            }
-            else
-            {
+            if(k==1){
+                System.out.printf("YES\n");
+            }else{
                 System.out.printf("NO\n");
             }
             
             
+            
         }