Go to diff to previous submission
#include <cstdio> #include <cmath> #include <iostream> #include <cstring> #include <cstdlib> using namespace std; int main() { int points, lines; int counts[10000]; while (scanf("%d %d", &points, &lines)) { memset(counts, 0, sizeof(*counts) * points); bool x = false; while (lines--) { int f, s; scanf("%d %d", &f, &s); if (++counts[f - 1] == 4) { printf("YES\n"); x = true; break; } if (++counts[s - 1] == 4) { printf("YES\n"); x = true; break; } } if (!x) printf("NO\n"); } return 0; }
--- 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; } }