Submission #628427

#TimeUsernameProblemLanguageResultExecution timeMemory
628427c28dnv9q3Rarest Insects (IOI22_insects)C++17
10 / 100
334 ms276 KiB
#include "insects.h" #include <vector> #include <numeric> #include <map> using namespace std; vector<int> p; int ufind(int i) { if (p[i] == i) return i; return p[i] = ufind(p[i]); } void umerge(int a, int b) { p[a] = b; } int min_cardinality(int N) { p.resize(N); iota(p.begin(), p.end(), 0); for (int i = 0; i < N-1; i++) { move_inside(i); for (int j = i+1; j < N; j++) { if (ufind(i) == ufind(j)) continue; move_inside(j); int k = press_button(); if (k == 2) umerge(i, j); move_outside(j); } move_outside(i); } map<int,int> m; for (int i = 0; i < N; i++) m[ufind(i)]++; int ans = N; for (auto it = m.begin(); it != m.end(); it++) ans = min(ans, it->second); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...