Source code for submission s581

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.Scanner;
  10.  
  11. /**
  12.  *
  13.  * @author kuric10
  14.  */
  15. public class Main {
  16.  
  17. /**
  18.   * @param args the command line arguments
  19.   */
  20. public static void main(String[] args)throws Exception{
  21. // TODO code application logic here
  22. // String s=input.readLine();
  23. String pole[];
  24. int poc[]=new int[10001];
  25. //int spoje[][]
  26. int max;
  27. int prve;
  28. int druhe;
  29. int links;
  30. /* while(1==1){
  31.   prve=input.read();
  32.   input.read();
  33.   druhe=input.read();
  34.   input.read();
  35.   }*/
  36.  
  37. /* while(!s.equals(null)){
  38.   pole=s.split(" ");
  39.   max=Integer.parseInt(pole[0]);//nebol bz lepsi scanner ??
  40.   links=Integer.parseInt(pole[1]);
  41.   for (int i = 0; i < links; i++) {
  42.   s=input.readLine();
  43.   pole
  44.   }
  45.  
  46.   s=input.readLine();
  47.   }*/
  48. Scanner in= new Scanner(System.in);
  49. int pom;
  50. boolean b;
  51. while(in.hasNextInt()){
  52. b=false;
  53. max=in.nextInt();
  54. links=in.nextInt();
  55. // System.out.println(links);
  56. for (int i = 0; i < links; i++) {
  57. prve=in.nextInt();
  58. druhe=in.nextInt();
  59. if(prve>druhe){
  60. pom=prve;
  61. prve=druhe;
  62. druhe=pom;
  63. }
  64. poc[prve]++;
  65. poc[druhe]++;
  66. if(poc[prve]==4 || poc[druhe]==4){
  67. b=true;
  68. break;
  69. }
  70. }
  71. if(b){
  72. System.out.println("YES");
  73. }else{
  74. System.out.println("NO");
  75. }
  76. for (int i = 0; i < max+1; i++) {
  77. poc[i]=0;
  78. }
  79.  
  80. }
  81. }
  82. }
  83.