제출 #484648

#제출 시각아이디문제언어결과실행 시간메모리
484648AmirElarbi버섯 세기 (IOI20_mushrooms)C++14
컴파일 에러
0 ms0 KiB
#include "mushrooms.h"
 
#include <bits/stdc++.h>
 
 #define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define fi first
#define se second
#define INF 1e7
#define eps 1e-18
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9+7;
const int nax = 2000005;
 
 
 
int count_mushrooms(int n) {
    int X = 199;
    vi typ[2];
    for(int i = 1; i <= min(n-1,X); i++){
        typ[use_machine({0,i})].pb(i);
    }
    int cnt = typ[0].size()+1;
    for (int i = 200; i < n; i+=200)
    {
        vi a;
        for(int j = i; j < i+typ[0].size() && j < n;j++){
            a.pb(typ[0][j-i]);
            a.pb(j);
        }
        int res = use_machine(a);
        cnt += min(typ[0].size(),n-i)-((res+1)/2);
        a.clear();
        for(int j = i+typ[0].size(); j < i+200 && j < n;j++){
            a.pb(typ[1][j-i-typ[0].size()]);
            a.pb(j);
        }
        res = use_machine(a);
        cnt += ((res+1)/2);
    }
    return cnt;
 
}

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:39:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int j = i; j < i+typ[0].size() && j < n;j++){
      |                        ~~^~~~~~~~~~~~~~~~~
mushrooms.cpp:44:37: error: no matching function for call to 'min(std::vector<int>::size_type, int)'
   44 |         cnt += min(typ[0].size(),n-i)-((res+1)/2);
      |                                     ^
In file included from /usr/include/c++/10/vector:60,
                 from mushrooms.h:1,
                 from mushrooms.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:
mushrooms.cpp:44:37: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   44 |         cnt += min(typ[0].size(),n-i)-((res+1)/2);
      |                                     ^
In file included from /usr/include/c++/10/vector:60,
                 from mushrooms.h:1,
                 from mushrooms.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:
mushrooms.cpp:44:37: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   44 |         cnt += min(typ[0].size(),n-i)-((res+1)/2);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:3:
/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:
mushrooms.cpp:44:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   44 |         cnt += min(typ[0].size(),n-i)-((res+1)/2);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:3:
/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:
mushrooms.cpp:44:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   44 |         cnt += min(typ[0].size(),n-i)-((res+1)/2);
      |                                     ^