제출 #1124311

#제출 시각아이디문제언어결과실행 시간메모리
1124311epicci23드문 곤충 (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
#include "insects.h" #include "bits/stdc++.h" using namespace std; const int N = 2e3 + 5; int vis[N], D , tot = 0 , Kill[N]; inline bool Add(int x){ if(vis[x] || Kill[x]) return 0; vis[x]=1; tot++; move_inside(x); return 1; } inline bool Rem(int x){ if(!vis[x] || Kill[x]) return 0; vis[x]=0; tot--; move_outside(x); return 1; } inline int Get(){ return press_button(); } int min_cardinality(int n){ for(int i=0;i<n;i++){ Add(i); if(i == 0 || Get() == 1) continue; Rem(i); } for(int i=0;i<n;i++) if(vis[i]) Kill[i] = 1; D = tot; if(D > n / 2) return 1; if(D == 1) return n; int ans = 1, l = 2 , r = n / D; while(l <= r){ int B = (l + r) / 2; for(int i=0;i<n;i++) if(!Kill[i]) Rem(i); vector<int> to_kill; for(int i = 0 ; i < n ; i++){ if(vis[i] || Kill[i]) continue; Add(i); if(tot > B && Get() > B){ Rem(i); to_kill.push_back(i); } } if(tot == B * D){ l = B + 1; ans = B; r = min(r, B + to_kill.size() / D); if(to_kill.size() < D) return ans; for(int i=0;i<n;i++) if(vis[i]) Kill[i] = 1; } else{ for(int x : to_kill) Kill[x] = 1; r = min(tot / D, B - 1); } } return ans; }

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

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:56:14: error: no matching function for call to 'min(int&, std::vector<int>::size_type)'
   56 |       r = min(r, B + to_kill.size() / D);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from insects.cpp:2:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
insects.cpp:56:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   56 |       r = min(r, B + to_kill.size() / D);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from insects.cpp:2:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
insects.cpp:56:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   56 |       r = min(r, B + to_kill.size() / D);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from insects.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
insects.cpp:56:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |       r = min(r, B + to_kill.size() / D);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from insects.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
insects.cpp:56:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |       r = min(r, B + to_kill.size() / D);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~