Submission #628923

#TimeUsernameProblemLanguageResultExecution timeMemory
628923flashmtRarest Insects (IOI22_insects)C++17
25 / 100
332 ms336 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; vector<int> findFirstOccurrences(int n, vector<int> &id) { vector<int> res; for (int i = 0; i < n; i++) if (id[i] < 0) { move_inside(i); if (press_button() > 1) move_outside(i); else { id[i] = size(res); res.push_back(i); } } for (int i : res) move_outside(i); return res; } int min_cardinality(int n) { vector<int> id(n, -1); auto occurrences = findFirstOccurrences(n, id); int typeCnt = size(occurrences); int maxC = n / typeCnt; if (maxC <= typeCnt) { int ans = 1; while (1) { auto occ = findFirstOccurrences(n, id); if (size(occ) != typeCnt) return ans; ans++; } } vector<int> cnt(n); for (int i = 0; i < n; i++) if (id[i] < 0) { move_inside(i); for (int j : occurrences) { move_inside(j); if (press_button() == 2) { cnt[j]++; move_outside(j); break; } move_outside(j); } move_outside(i); } int ans = n; for (int x : occurrences) ans = min(ans, cnt[x] + 1); return ans; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:37:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |       if (size(occ) != typeCnt)
      |           ~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...