제출 #1344945

#제출 시각아이디문제언어결과실행 시간메모리
1344945ChocoA Difficult(y) Choice (BOI21_books)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
#pragma GCC optimize("O3")
#define ll long long 
#define double double long
#define fori(i,j,k) for(ll i=j; i<=k;i++)
#define study ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define all(s) s.begin(),s.end()
#define ins insert
#define ss second
#define ff first
#ifndef DB
#define DB 0
#endif
#define debugl(l) if constexpr((l)<DB)
#define debug debugl(0)
const ll sz=1e4+10;
ll INF=1e9;
ll mod=1e9+7;

//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
//     books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ books_sample.cpp sample_grader.cpp
// in this folder.
//
void solve(int N, int K, long long A, int S) {
    vector<ll>v(N+10,0);
    ll l=1,r=N;
    while(l<=r){
        ll mid=(l+r)>>1;
        if(v[mid]==0)
        v[mid]=skim(mid);
        if(v[mid]>A){
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    r++;
    r=min(N,r);
    set<ll>st;
    fori(i,1,K){
        st.ins(i);
    }
    fori(i,max(1LL,r-K+1),r)
    st.ins(i);
    vector<int>idk;
    for(auto x: st){
        if(v[x]==0)
        v[x]=skim(x);
        idk.pb(x);
    }
    vector<int>ans;
    ll ah=idk.size();
    fori(mask,0,(1<<(ah))-1){
        ll sum=0;
        vector<int>cur;
        fori(j,0,ah-1){
            if((1<<j)&mask){
                sum+=v[idk[j]];
                cur.pb(idk[j]);
            }
        }
        if(cur.size()!=K)
        continue;
        if(sum>=A and sum<=(2*A)){
            ans=cur;
            break;
        }
    }
    if(ans.size()==K)
    answer(ans);
    else
    impossible();
}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:47:10: error: no matching function for call to 'min(int&, long long int&)'
   47 |     r=min(N,r);
      |       ~~~^~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from books.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
books.cpp:47:10: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   47 |     r=min(N,r);
      |       ~~~^~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
books.cpp:47:10: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   47 |     r=min(N,r);
      |       ~~~^~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
books.cpp:47:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |     r=min(N,r);
      |       ~~~^~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
books.cpp:47:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |     r=min(N,r);
      |       ~~~^~~~~