Submission #726704

#TimeUsernameProblemLanguageResultExecution timeMemory
726704TheSahibRarest 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); } } shuffle(left.begin(), left.end()); 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:21:37: error: no matching function for call to 'shuffle(std::vector<int>::iterator, std::vector<int>::iterator)'
   21 |     shuffle(left.begin(), left.end());
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from insects.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3748:5: note: candidate: 'template<class _RAIter, class _UGenerator> void std::shuffle(_RAIter, _RAIter, _UGenerator&&)'
 3748 |     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3748:5: note:   template argument deduction/substitution failed:
insects.cpp:21:37: note:   candidate expects 3 arguments, 2 provided
   21 |     shuffle(left.begin(), left.end());
      |                                     ^
insects.cpp:30:32: error: 'type' was not declared in this scope; did you mean 'types'?
   30 |             if(inside == mid * type.size()){
      |                                ^~~~
      |                                types
insects.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if(inside == mid * types.size()){
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~