제출 #886578

#제출 시각아이디문제언어결과실행 시간메모리
886578thinknoexit드문 곤충 (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; using ll = long long; int n; int sz = 0; bool mark[2020]; void putin(int x) { move_inside(x); sz++; } void putout(int x) { move_outside(x); sz--; } int val() { return press_button(); } int min_cardinality(int N) { n = N; vector<int> a(n); for (int i = 0;i < n;i++) a[i] = i; shuffle(a.begin(), a.end()); putin(a[0]); mark[a[0]] = 1; for (int i = 1;i < n;i++) { putin(a[i]); if (val() == 2) { putout(a[i]); } else { mark[a[i]] = 1; } } int type = sz; if (type == n) return 1; int l = 1, r = n / sz; while (l < r) { int mid = (l + r + 1) / 2; stack<int> st, st2; for (int i = 0;i < n;i++) { if (sz == type * mid) break; if (mark[a[i]]) continue; putin(a[i]); if (val() > mid) { putout(a[i]); mark[a[i]] = 1; st2.push(a[i]); } else { st.push(a[i]); } } if (sz == type * mid) { while (!st.empty()) { mark[st.top()] ^= 1; st.pop(); } while (!st2.empty()) { mark[st2.top()] ^= 1; st2.pop(); } l = mid; } else { if (l == mid - 1) return l; while (!st.empty()) { putout(st.top()); st.pop(); } r = mid - 1; } } return l; }

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:23:31: error: no matching function for call to 'shuffle(std::vector<int>::iterator, std::vector<int>::iterator)'
   23 |     shuffle(a.begin(), a.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:1:
/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:23:31: note:   candidate expects 3 arguments, 2 provided
   23 |     shuffle(a.begin(), a.end());
      |                               ^