Submission #629293

#TimeUsernameProblemLanguageResultExecution timeMemory
629293jakubdRarest Insects (IOI22_insects)C++17
0 / 100
1 ms208 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { int D = 1; vector<int> inside(N), outside(N), leader(N); move_inside(0); inside[0] = leader[0] = 1; for (int i = 1; i < N; i++) { move_inside(i); if (press_button() == 2) { move_outside(i); outside[i] = 1; } else { D++; inside[i] = leader[i] = 1; } } int l = 2, r = N / D, cur = D, ans = 1; while (l <= r) { int m = (l + r) / 2; vector<int> last; for (int i = 0; i < N; i++) { if (inside[i]) continue; move_inside(i); if (press_button() > m) { move_outside(i); } else { last.push_back(i); inside[i] = 1; outside[i] = 0; cur++; } } if (cur >= D * m) { l = m + 1; ans = m; } else { r = m - 1; for (auto x : last) { move_outside(x); inside[x] = 0; outside[x] = 1; cur--; } } } return l; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:23:34: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   23 |   int l = 2, r = N / D, cur = D, ans = 1;
      |                                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...