Source code for submission s794

Go to diff to previous submission

fn.cpp

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

Diff to submission s735

fn.cpp

--- c5.s735.cteam044.fn.cpp.0.fn.cpp
+++ c5.s794.cteam044.fn.cpp.0.fn.cpp
@@ -2,6 +2,5 @@
 #include <cmath>
 #include <iostream>
-#include <string>
-#include <map>
+#include <cstring>
 #include <cstdlib>
 
@@ -12,7 +11,8 @@
 {
         int points, lines;
+        int counts[10000];
         while (scanf("%d %d", &points, &lines))
         {
-                std::map<int, int> counts;
+                memset(counts, 0, sizeof(*counts) * points);
                 bool x = false;
                 while (lines--)
@@ -20,26 +20,15 @@
                         int f, s;
                         scanf("%d %d", &f, &s);
-                        if (counts.find(f) == counts.end())
-                                counts[f] = 1;
-                        else
+                        if (++counts[f - 1] == 4)
                         {
-                                if (++counts[f] >= 4)
-                                {
-                                        printf("YES\n");
-                                        x = true;
-                                        break;
-                                }
+                                printf("YES\n");
+                                x = true;
+                                break;
                         }
-                                
-                        if (counts.find(s) == counts.end())
-                                counts[s] = 1;
-                        else
+                        if (++counts[s - 1] == 4)
                         {
-                                if (++counts[s] >= 4)
-                                {
-                                        printf("YES\n");
-                                        x = true;
-                                        break;
-                                }
+                                printf("YES\n");
+                                x = true;
+                                break;
                         }
                 }