Submission #1314532

#TimeUsernameProblemLanguageResultExecution timeMemory
1314532PlayVoltzRarest Insects (IOI22_insects)C++20
Compilation error
0 ms0 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second int min_cardinality(int n){ int uq=1; move_inside(0); vector<bool> got(n, 0), ban(n, 0); got[0]=1; for (int i=1; i<n; ++i){ move_inside(i); got[i]=1; if (press_button()==2)move_outside(i), got[i]=0; else ++uq; } int low=1, high=n/uq+1, prev=1; while (low+1<high){ int mid=(low+high)/2, c=0, b=0; vector<bool> toomuch(n, 0), added(n, 0); for (int i=0; i<n; ++i)if (got[i])++c; for (int i=0; i<n; ++i)if (!ban[i])++b; if (b<uq*mid){ high=mid; continue; } int extra=max(0ll, mid-prev); for (int i=0; i<n; ++i)if (!got[i]&&!ban[i]){ move_inside(i); got[i]=1; added[i]=1; if (extra)--extra, ++c; else{ int res=press_button(); if (res>mid)move_outside(i), got[i]=0, added[i]=0, toomuch[i]=1; else ++c, extra=mid-res; } if (c==uq*mid)break; } if (c==uq*mid)low=mid; else{ high=mid; for (int i=0; i<n; ++i)if (added[i])move_outside(i), got[i]=0; for (int i=0; i<n; ++i)if (toomuch[i])ban[i]=1; } prev=mid; } return low; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:32:30: error: no matching function for call to 'max(long long int, int)'
   32 |                 int extra=max(0ll, mid-prev);
      |                           ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from insects.cpp:2:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
insects.cpp:32:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |                 int extra=max(0ll, mid-prev);
      |                           ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
insects.cpp:32:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |                 int extra=max(0ll, mid-prev);
      |                           ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
insects.cpp:32:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |                 int extra=max(0ll, mid-prev);
      |                           ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
insects.cpp:32:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |                 int extra=max(0ll, mid-prev);
      |                           ~~~^~~~~~~~~~~~~~~