Submission #837954

#TimeUsernameProblemLanguageResultExecution timeMemory
837954taherRarest Insects (IOI22_insects)C++17
10 / 100
236 ms336 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; class dsu { public: int n; vector<int> par; vector<int> size; dsu(int _n) : n(_n) { par.resize(n); iota(par.begin(), par.end(), 0); size.resize(n); for (int i = 0; i < n; i++) { size[i] = 1; } } int get(int x) { if (par[x] == x) { return par[x]; } return par[x] = get(par[x]); } bool unite(int x, int y) { x = get(x); y = get(y); if (x == y) { return false; } par[x] = y; size[y] += size[x]; return true; } }; int min_cardinality(int N) { int n = N; dsu ds(n); for (int i = 0; i < n; i++) { move_inside(i); for (int j = i + 1; j < n; j++) { move_inside(j); if (press_button() == 2) { ds.unite(i, j); } move_outside(j); } move_outside(i); } int res = 123456; for (int i = 0; i < n; i++) { if (ds.get(i) == i) { res = min(res, ds.size[i]); } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...