Source code for submission s863

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.  
  51. k=1;
  52. }
  53. }
  54. if(k==1)
  55. {
  56. System.out.printf("YES\n");
  57. }
  58. else
  59. {
  60. System.out.printf("NO\n");
  61. }
  62.  
  63.  
  64. }
  65.  
  66. }
  67. }
  68.