Source code for submission s735

fn.cpp

  1. #include <cstdio>
  2. #include <cmath>
  3. #include <iostream>
  4. #include <string>
  5. #include <map>
  6. #include <cstdlib>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int main()
  12. {
  13. int points, lines;
  14. while (scanf("%d %d", &points, &lines))
  15. {
  16. std::map<int, int> counts;
  17. bool x = false;
  18. while (lines--)
  19. {
  20. int f, s;
  21. scanf("%d %d", &f, &s);
  22. if (counts.find(f) == counts.end())
  23. counts[f] = 1;
  24. else
  25. {
  26. if (++counts[f] >= 4)
  27. {
  28. printf("YES\n");
  29. x = true;
  30. break;
  31. }
  32. }
  33.  
  34. if (counts.find(s) == counts.end())
  35. counts[s] = 1;
  36. else
  37. {
  38. if (++counts[s] >= 4)
  39. {
  40. printf("YES\n");
  41. x = true;
  42. break;
  43. }
  44. }
  45. }
  46. if (!x)
  47. printf("NO\n");
  48. }
  49.  
  50. return 0;
  51. }
  52.