Submission #305948

# Submission time Handle Problem Language Result Execution time Memory
305948 2020-09-24T06:38:30 Z llaki Packing Biscuits (IOI20_biscuits) C++17
Compilation error
0 ms 0 KB
#include <vector>
#include <map>
#include "biscuits.h"

long long count_tastiness(long long x, std::vector<long long> a) {
	std::map<long long, long long>* freq;
	freq[a[0]] = 1;
	for (int pos = 0; pos < a.size() - 1; pos++) {
		std::map<long long, long long> map;
		for (const auto &[y, value]: freq) {
			long long val = a[pos + 1] + y / 2;
			long long oldFreq = 0;
			if (map.find(val) != map.end()) {
				oldFreq = map[val];
			}
			map[val] = oldFreq + freq[y];
			if (y >= x) {
				val = a[pos + 1] + (y - x) / 2;
				oldFreq = 0;
				if (map.find(val) != map.end()) {
					oldFreq = map[val];
				}
				map[val] = oldFreq + freq[y];
			}
		}
		freq = &map;
	}
	long long ans = 0;
	for (const auto &[y, value]: freq) {
		ans += value * (y / x + 1);
	}
	return ans;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:7:15: error: no match for 'operator=' (operand types are 'std::map<long long int, long long int>' and 'int')
    7 |  freq[a[0]] = 1;
      |               ^
In file included from /usr/include/c++/9/map:61,
                 from biscuits.cpp:2:
/usr/include/c++/9/bits/stl_map.h:317:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  317 |       operator=(const map&) = default;
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:317:17: note:   no known conversion for argument 1 from 'int' to 'const std::map<long long int, long long int>&'
  317 |       operator=(const map&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/9/bits/stl_map.h:321:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::map<_Key, _Tp, _Compare, _Alloc>&&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  321 |       operator=(map&&) = default;
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:321:17: note:   no known conversion for argument 1 from 'int' to 'std::map<long long int, long long int>&&'
  321 |       operator=(map&&) = default;
      |                 ^~~~~
/usr/include/c++/9/bits/stl_map.h:335:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::initializer_list<std::pair<const _Key, _Tp> >) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
  335 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:335:46: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::pair<const long long int, long long int> >'
  335 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
biscuits.cpp:8:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int pos = 0; pos < a.size() - 1; pos++) {
      |                    ~~~~^~~~~~~~~~~~~~
biscuits.cpp:10:32: error: no matching function for call to 'begin(std::map<long long int, long long int>*&)'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
In file included from /usr/include/c++/9/utility:76,
                 from /usr/include/c++/9/bits/stl_uninitialized.h:60,
                 from /usr/include/c++/9/vector:66,
                 from biscuits.cpp:1:
/usr/include/c++/9/initializer_list:89:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
   89 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/9/initializer_list:89:5: note:   template argument deduction/substitution failed:
biscuits.cpp:10:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::map<long long int, long long int>*'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:48:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   48 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:48:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::map<long long int, long long int>*]':
biscuits.cpp:10:32:   required from here
/usr/include/c++/9/bits/range_access.h:48:50: error: request for member 'begin' in '__cont', which is of pointer type 'std::map<long long int, long long int>*' (maybe you meant to use '->' ?)
   48 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |                                           ~~~~~~~^~~~~
/usr/include/c++/9/bits/range_access.h:58:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   58 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:58:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::map<long long int, long long int>*]':
biscuits.cpp:10:32:   required from here
/usr/include/c++/9/bits/range_access.h:58:56: error: request for member 'begin' in '__cont', which is of pointer type 'std::map<long long int, long long int>* const' (maybe you meant to use '->' ?)
   58 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |                                                 ~~~~~~~^~~~~
/usr/include/c++/9/bits/range_access.h:87:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   87 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:87:5: note:   template argument deduction/substitution failed:
biscuits.cpp:10:32: note:   mismatched types '_Tp [_Nm]' and 'std::map<long long int, long long int>*'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:104:31: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
  104 |   template<typename _Tp> _Tp* begin(valarray<_Tp>&);
      |                               ^~~~~
/usr/include/c++/9/bits/range_access.h:104:31: note:   template argument deduction/substitution failed:
biscuits.cpp:10:32: note:   mismatched types 'std::valarray<_Tp>' and 'std::map<long long int, long long int>*'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:105:37: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
  105 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
      |                                     ^~~~~
/usr/include/c++/9/bits/range_access.h:105:37: note:   template argument deduction/substitution failed:
biscuits.cpp:10:32: note:   mismatched types 'const std::valarray<_Tp>' and 'std::map<long long int, long long int>*'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
biscuits.cpp:10:32: error: no matching function for call to 'end(std::map<long long int, long long int>*&)'
In file included from /usr/include/c++/9/utility:76,
                 from /usr/include/c++/9/bits/stl_uninitialized.h:60,
                 from /usr/include/c++/9/vector:66,
                 from biscuits.cpp:1:
/usr/include/c++/9/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/9/initializer_list:99:5: note:   template argument deduction/substitution failed:
biscuits.cpp:10:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::map<long long int, long long int>*'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:68:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   68 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/9/bits/range_access.h:68:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = std::map<long long int, long long int>*]':
biscuits.cpp:10:32:   required from here
/usr/include/c++/9/bits/range_access.h:68:48: error: request for member 'end' in '__cont', which is of pointer type 'std::map<long long int, long long int>*' (maybe you meant to use '->' ?)
   68 |     end(_Container& __cont) -> decltype(__cont.end())
      |                                         ~~~~~~~^~~
/usr/include/c++/9/bits/range_access.h:78:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   78 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/9/bits/range_access.h:78:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = std::map<long long int, long long int>*]':
biscuits.cpp:10:32:   required from here
/usr/include/c++/9/bits/range_access.h:78:54: error: request for member 'end' in '__cont', which is of pointer type 'std::map<long long int, long long int>* const' (maybe you meant to use '->' ?)
   78 |     end(const _Container& __cont) -> decltype(__cont.end())
      |                                               ~~~~~~~^~~
/usr/include/c++/9/bits/range_access.h:97:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
   97 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/9/bits/range_access.h:97:5: note:   template argument deduction/substitution failed:
biscuits.cpp:10:32: note:   mismatched types '_Tp [_Nm]' and 'std::map<long long int, long long int>*'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:106:31: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
  106 |   template<typename _Tp> _Tp* end(valarray<_Tp>&);
      |                               ^~~
/usr/include/c++/9/bits/range_access.h:106:31: note:   template argument deduction/substitution failed:
biscuits.cpp:10:32: note:   mismatched types 'std::valarray<_Tp>' and 'std::map<long long int, long long int>*'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:107:37: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
  107 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
      |                                     ^~~
/usr/include/c++/9/bits/range_access.h:107:37: note:   template argument deduction/substitution failed:
biscuits.cpp:10:32: note:   mismatched types 'const std::valarray<_Tp>' and 'std::map<long long int, long long int>*'
   10 |   for (const auto &[y, value]: freq) {
      |                                ^~~~
biscuits.cpp:29:31: error: no matching function for call to 'begin(std::map<long long int, long long int>*&)'
   29 |  for (const auto &[y, value]: freq) {
      |                               ^~~~
In file included from /usr/include/c++/9/utility:76,
                 from /usr/include/c++/9/bits/stl_uninitialized.h:60,
                 from /usr/include/c++/9/vector:66,
                 from biscuits.cpp:1:
/usr/include/c++/9/initializer_list:89:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
   89 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/9/initializer_list:89:5: note:   template argument deduction/substitution failed:
biscuits.cpp:29:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::map<long long int, long long int>*'
   29 |  for (const auto &[y, value]: freq) {
      |                               ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:48:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   48 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:48:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::map<long long int, long long int>*]':
biscuits.cpp:29:31:   required from here
/usr/include/c++/9/bits/range_access.h:48:50: error: request for member 'begin' in '__cont', which is of pointer type 'std::map<long long int, long long int>*' (maybe you meant to use '->' ?)
   48 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |                                           ~~~~~~~^~~~~
/usr/include/c++/9/bits/range_access.h:58:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   58 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:58:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::map<long long int, long long int>*]':
biscuits.cpp:29:31:   required from here
/usr/include/c++/9/bits/range_access.h:58:56: error: request for member 'begin' in '__cont', which is of pointer type 'std::map<long long int, long long int>* const' (maybe you meant to use '->' ?)
   58 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |                                                 ~~~~~~~^~~~~
/usr/include/c++/9/bits/range_access.h:87:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   87 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:87:5: note:   template argument deduction/substitution failed:
biscuits.cpp:29:31: note:   mismatched types '_Tp [_Nm]' and 'std::map<long long int, long long int>*'
   29 |  for (const auto &[y, value]: freq) {
      |                               ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:104:31: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
  104 |   template<typename _Tp> _Tp* begin(valarray<_Tp>&);
      |                               ^~~~~
/usr/include/c++/9/bits/range_access.h:104:31: note:   template argument deduction/substitution failed:
biscuits.cpp:29:31: note:   mismatched types 'std::valarray<_Tp>' and 'std::map<long long int, long long int>*'
   29 |  for (const auto &[y, value]: freq) {
      |                               ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:105:37: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
  105 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
      |                                     ^~~~~
/usr/include/c++/9/bits/range_access.h:105:37: note:   template argument deduction/substitution failed:
biscuits.cpp:29:31: note:   mismatched types 'const std::valarray<_Tp>' and 'std::map<long long int, long long int>*'
   29 |  for (const auto &[y, value]: freq) {
      |                               ^~~~
biscuits.cpp:29:31: error: no matching function for call to 'end(std::map<long long int, long long int>*&)'
In file included from /usr/include/c++/9/utility:76,
                 from /usr/include/c++/9/bits/stl_uninitialized.h:60,
                 from /usr/include/c++/9/vector:66,
                 from biscuits.cpp:1:
/usr/include/c++/9/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/9/initializer_list:99:5: note:   template argument deduction/substitution failed:
biscuits.cpp:29:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::map<long long int, long long int>*'
   29 |  for (const auto &[y, value]: freq) {
      |                               ^~~~
In file included from /usr/include/c++/9/vector:69,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/range_access.h:68:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   68 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/9/bits/range_access.h:68:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = std::map<long long int, long long int>*]':
biscuits.cpp:29:31:   required from here
/usr/include/c++/9/bits/range_access.h:68:48: error: request for member 'end' in '__cont', which is of pointer type 'std::map<long long int, long long int>*' (maybe you meant to use '->' ?)
   68 |     end(_Container& __cont) -> decltype(__cont.end())
      |                                         ~~~~~~~^~~
/usr/include/c++/9/bits/range_access.h:78:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   78 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/9/bits/range_access.h:78:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = std::map<long long int, long long int>*]':
biscuits.cpp:29:31:   required from here
/usr/include