Submission #794432

#TimeUsernameProblemLanguageResultExecution timeMemory
794432IvanJRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include<bits/stdc++.h> #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 2005; int n, D, step; int vis[maxn]; int forb[maxn]; vector<ii> in; vector<int> p; int check(int x) { int y = -1, lst = 0; random_shuffle(p); for(int i : p) { if(vis[i] || forb[i]) continue; move_inside(i); int cnt = press_button(); if(lst < x && cnt == x) y = i; if(cnt > x) move_outside(i), forb[i] = 1; else in.pb({i, step}), vis[i] = 1; if((int)in.size() == x * D) return 1; lst = cnt; } if(y != -1) forb[y] = 1; return 0; } int min_cardinality(int N) { srand(time(0)); n = N, D = 0, step = 1; for(int i = 0;i < n;i++) p.pb(i); random_shuffle(all(p)); for(int i : p) { move_inside(i); if(press_button() > 1) move_outside(i); else in.pb({i, step}), vis[i] = 1, D++; } int lo = 1, hi = n / D, ans = 1; while(lo <= hi) { step++; int mid = (lo + hi) / 2; if(hi == 1) break; int flag = check(mid); if(flag) { ans = mid, lo = mid + 1; for(int i = 0;i < n;i++) forb[i] = 0; } else { hi = mid - 1; while(in.back().y == step) move_outside(in.back().x), vis[in.back().x] = 0, in.pop_back(); } } return ans; }

Compilation message (stderr)

insects.cpp: In function 'int check(int)':
insects.cpp:24:18: error: no matching function for call to 'random_shuffle(std::vector<int>&)'
   24 |  random_shuffle(p);
      |                  ^
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:4585:5: note: candidate: 'template<class _RAIter> void std::random_shuffle(_RAIter, _RAIter)'
 4585 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:4585:5: note:   template argument deduction/substitution failed:
insects.cpp:24:18: note:   candidate expects 2 arguments, 1 provided
   24 |  random_shuffle(p);
      |                  ^
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:4620:5: note: candidate: 'template<class _RAIter, class _Generator> void std::random_shuffle(_RAIter, _RAIter, _Generator&&)'
 4620 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:4620:5: note:   template argument deduction/substitution failed:
insects.cpp:24:18: note:   candidate expects 3 arguments, 1 provided
   24 |  random_shuffle(p);
      |                  ^