Source code for submission s501

Fn.java

  1. import java.io.*;
  2. public class Fn{
  3. static String[] input;
  4. static String line;
  5. static int noNodes;
  6. static int noLines;
  7. static int[] nodes; //deg of nodes
  8. static String answer;
  9. public static void main(String[] args) throws IOException{
  10.  
  11. while((line = reader.readLine()) != null){
  12. answer = "NO";
  13. input = line.split(" ");
  14. noNodes = Integer.parseInt(input[0]);
  15. noLines = Integer.parseInt(input[1]);
  16. nodes = new int[noNodes];
  17.  
  18. for(int i = 0; i<noLines; i++){
  19. input = reader.readLine().split(" ");
  20. insertNode(Integer.parseInt(input[0]),Integer.parseInt(input[1]));
  21. }
  22. System.out.println(answer);
  23. }
  24.  
  25. }
  26.  
  27. static void insertNode(int a, int b){
  28. nodes[a-1]++;
  29. nodes[b-1]++;
  30. if(nodes[a-1] == 4){
  31. answer = "YES";
  32. }
  33. if(nodes[b-1] == 4){
  34. answer = "YES";
  35. }
  36. }
  37. }