Submission #859286

# Submission time Handle Problem Language Result Execution time Memory
859286 2023-10-10T03:22:47 Z MasterDobby Rarest Insects (IOI22_insects) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "insects.h"
#define all(a) a.begin(),a.end()
#define pii pair<int,int>

using namespace std;
using ll = long long;

int ch[2020];

int min_cardinality(int n){
    int cnt=1,mx=0;
    ch[0]=1;
    move_inside(0);
    for(int i=1;i<n;i++){
        move_inside(i);
        int num=press_button();
        if(num==1){
            ch[i]=1;
            cnt++;
            mx=n-i;
        }
        else{
            move_outside(i);
        }
    }
    if(cnt==1) return n;
    for(int i=1;i<=n;i++){
        if(ch[i]) continue;
        move_inside(i);
    }
    mx=min(mx,press_button);
    for(int i=1;i<=n;i++){
        if(ch[i]) continue;
        move_outside(i);
    }
    int l=1,r=min((int)n/cnt,mx),now=cnt;
    while(l<r){
        int mid=(l+r+1)/2;
        int cnt2=now;
        vector<int> nw;
        for(int j=0;j<n;j++){
            if(cnt2==mid*cnt) break;
            if(ch[j]) continue;
            nw.push_back(j);
            move_inside(j);
            int num=press_button();
            if(num<=mid){
                ch[j]=1;
                cnt2++;
            }
            else{
                move_outside(j);
            }
        }
        if(cnt2==mid*cnt) l=mid,now=cnt2;
        else{
            r=mid-1;
            for(auto x:nw) move_outside(x),ch[x]=0;
        }
    }
    return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:32:27: error: no matching function for call to 'min(int&, int (&)())'
   32 |     mx=min(mx,press_button);
      |                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from insects.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
insects.cpp:32:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int()')
   32 |     mx=min(mx,press_button);
      |                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from insects.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
insects.cpp:32:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int()')
   32 |     mx=min(mx,press_button);
      |                           ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
insects.cpp:32:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |     mx=min(mx,press_button);
      |                           ^
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:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
insects.cpp:32:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |     mx=min(mx,press_button);
      |                           ^