Submission #1059987

#TimeUsernameProblemLanguageResultExecution timeMemory
1059987DorostWefRarest Insects (IOI22_insects)C++17
99.76 / 100
45 ms848 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { vector <int> a; int n = N; int k = 0; vector <int> d; for (int i = 0; i < n; i++) { move_inside (i); if (press_button() >= 2) { move_outside (i); a.push_back(i); } else { d.push_back(i); k++; } } for (int i : d) move_outside (i); int ans = 1; while ((int)a.size() >= k) { n = (int)a.size(); // cout << n << endl; int m = n / (k); m = max (1, (m) / 2); int cnt = 0; vector <int> b, c; for (int i = 0; i < n; i++) { move_inside (a[i]); if (press_button() > m) { b.push_back (a[i]); move_outside (a[i]); } else { cnt++; c.push_back (a[i]); } } for (int i : c) move_outside (i); if (cnt == k * m) { a = b; ans += m; } else { a = c; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...