Submission #726707

#TimeUsernameProblemLanguageResultExecution timeMemory
726707TheSahibRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { vector<int> types; vector<int> left; for (int i = 0; i < N; i++) { move_inside(i); if(press_button() > 1){ left.push_back(i); move_outside(i); } else{ types.push_back(i); } } int inside = types.size(); int l = 2, r = N / types.size(); int ans = 1; while(l <= r){ vector<int> tmp; int mid = (l + r) / 2; for(int a:left){ if(inside == mid * type.size()){ tmp.push_back(a); continue; } move_inside(a); ++inside; if(press_button() > mid){ move_outside(a); tmp.push_back(a); --inside; } } if(inside == mid * types.size()){ l = mid + 1; ans = mid; left = tmp; } else{ r = mid - 1; vector<int> tmp1; for(int a:left){ if(find(tmp.begin(), tmp.end(), a) == tmp.end()){ --inside; move_outside(a); tmp1.push_back(a); } } left = tmp1; } } return ans; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:29:32: error: 'type' was not declared in this scope; did you mean 'types'?
   29 |             if(inside == mid * type.size()){
      |                                ^~~~
      |                                types
insects.cpp:42:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         if(inside == mid * types.size()){
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~