Submission #628916

#TimeUsernameProblemLanguageResultExecution timeMemory
628916flashmtRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 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 = *max_element(begin(cnt), end(cnt)) + 1; return ans; } int main() { assert(1 == scanf("%d", &N)); color.resize(N); in_box.assign(N, false); std::map<int, int> type_to_color; for (int i = 0; i < N; ++i) { int Ti; assert(1 == scanf("%d", &Ti)); if (type_to_color.find(Ti) == type_to_color.end()) { int new_color = type_to_color.size(); type_to_color[Ti] = new_color; max_occurrences.insert(0); } color[i] = type_to_color[Ti]; } color_occurrences.assign(type_to_color.size(), 0); int answer = min_cardinality(N); int Q = *std::max_element(op_counter.begin(), op_counter.end()); printf("%d\n", answer); printf("%d\n", Q); return 0; }

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)
      |           ~~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from insects.cpp:1:
insects.cpp: In function 'int main()':
insects.cpp:67:28: error: 'N' was not declared in this scope
   67 |   assert(1 == scanf("%d", &N));
      |                            ^
insects.cpp:68:3: error: 'color' was not declared in this scope
   68 |   color.resize(N);
      |   ^~~~~
insects.cpp:69:3: error: 'in_box' was not declared in this scope
   69 |   in_box.assign(N, false);
      |   ^~~~~~
insects.cpp:78:7: error: 'max_occurrences' was not declared in this scope
   78 |       max_occurrences.insert(0);
      |       ^~~~~~~~~~~~~~~
insects.cpp:83:3: error: 'color_occurrences' was not declared in this scope
   83 |   color_occurrences.assign(type_to_color.size(), 0);
      |   ^~~~~~~~~~~~~~~~~
insects.cpp:86:29: error: 'op_counter' was not declared in this scope
   86 |   int Q = *std::max_element(op_counter.begin(), op_counter.end());
      |                             ^~~~~~~~~~