Source code for submission s476

fn.cpp

  1. //
  2. // File: f1.cc
  3. // Author: cteam029
  4. //
  5. // Created on October 19, 2013, 10:26 AM
  6. //
  7.  
  8. #include <cstdlib>
  9. #include <cstdio>
  10. #include <map>
  11.  
  12. using namespace std;
  13.  
  14. //
  15. //
  16. //
  17. int main(int argc, char** argv) {
  18. map<int, int> mapa;
  19. int a, b, x, y;
  20. bool ok;
  21. while(scanf("%d%d", &a, &b) == 2){
  22. ok = false;
  23. for(int i = 0; i < b; i++){
  24. if(scanf("%d%d", &x, &y) == 2){
  25. if(mapa.find(x) == mapa.end()){
  26. mapa.insert(pair<int, int>(x, 1));
  27. }else{
  28. mapa[x]++;
  29. }
  30. if(mapa.find(y) == mapa.end()){
  31. mapa.insert(pair<int, int>(y, 1));
  32. }else{
  33. mapa[y]++;
  34. }
  35. }
  36. }
  37. for(map<int, int>::iterator it = mapa.begin(); it != mapa.end(); ++it){
  38. if((*it).second >= 4){
  39. ok = true;
  40. break;
  41. }
  42. }
  43. if(ok){
  44. printf("YES\n");
  45. }else{
  46. printf("NO\n");
  47. }
  48. }
  49.  
  50. return 0;
  51. }
  52.  
  53.