답안 #938942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938942 2024-03-06T00:41:53 Z irmuun 드문 곤충 (IOI22_insects) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "insects.h"
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
 
int min_cardinality(int n){
    int d=0;
    set<int>st;
    for(int i=0;i<n;i++){
        d++;
        move_inside(i);
        st.insert(i);
        int cnt=press_button();
        if(cnt>1){
            move_outside(i);
            st.erase(i);
            d--;
        }
    }
    for(auto i:st){
        move_outside(i);
    }
    if(d<8){
        vector<int>type(n,0);
        int ans=n;
        for(int i=1;i<=d;i++){
            int cur=0;
            set<int>st;
            for(int j=0;j<n;j++){
                if(type[j]==0){
                    move_inside(j);
                    st.insert(j);
                    cur++;
                    int cnt=press_button();
                    if(cnt==cur){
                        type[j]=i;
                    }
                    else{
                        st.erase(j);
                        cur--;
                        move_outside(j);
                    }
                }
            }
            ans=min(ans,st.size());
            for(auto j:st){
                move_outside(j);
            }
        }
        return ans;
    }
    int l=1,r=n/d;
    while(l<r){
        int mid=(l+r+1)/2;
        int len=0;
        st.clear();
        for(int i=0;i<n;i++){
            len++;
            move_inside(i);
            st.insert(i);
            int cnt=press_button();
            if(cnt>mid){
                len--;
                move_outside(i);
                st.erase(i);
            }
        }
        if(len==d*mid){
            l=mid;
        }
        else{
            r=mid-1;
        }
        for(auto i:st){
            move_outside(i);
        }
    }
    return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:52:34: error: no matching function for call to 'min(int&, std::set<int>::size_type)'
   52 |             ans=min(ans,st.size());
      |                                  ^
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:52:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::set<int>::size_type' {aka 'long unsigned int'})
   52 |             ans=min(ans,st.size());
      |                                  ^
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:52:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::set<int>::size_type' {aka 'long unsigned int'})
   52 |             ans=min(ans,st.size());
      |                                  ^
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:52:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |             ans=min(ans,st.size());
      |                                  ^
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:52:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |             ans=min(ans,st.size());
      |                                  ^