Submission #1011351

#TimeUsernameProblemLanguageResultExecution timeMemory
1011351Double_SlashLanguages (IOI10_languages)C++17
Compilation error
0 ms0 KiB
#include "lang.h" #include "grader.h" #include <bits/stdc++.h> using namespace std; #define debug(x) [&] { auto _x = x; cerr << __LINE__ << ": " << #x << " = " << _x << endl; return _x; }() double magic(double x) { return pow(abs(x), 1); } template <typename T> struct Data : map<T, int> { int tot = 0; double operator&(const Data<T> &o) const { double ret = 0; for (auto [k, v]: *this) { ret += magic((double) v / tot - (o.count(k) ? (double) o.at(k) / o.tot : 0)); } for (auto [k, v]: o) { if (not count(k)) ret += magic((double) v / o.tot); } return ret; } void operator+=(const Data<T> &o) { for (auto &[k, v]: o) { (*this)[k] += v; } tot += o.tot; }}; struct Profile { Data<int> single; Profile() {} Profile(int *arr) { for (int i = 0; i < 100; ++i) { single[arr[i]]++; } single.tot = 100; } double operator&(const Profile &o) const { return single & o.single; } void operator+=(const Profile &o) { single += o.single; } } profile[56]; void excerpt(int *E) { Profile p(E); pair<double, int> mn{1e18, 0}; for (int i = 0; i < 56; ++i) { mn = min(mn, {p & profile[i], i}); } int ans = language(mn.second); profile[ans] += p; }

Compilation message (stderr)

lang.cpp: In instantiation of 'double Data<T>::operator&(const Data<T>&) const [with T = int]':
lang.cpp:47:21:   required from here
lang.cpp:22:17: error: no matching function for call to 'count(std::tuple_element<0, std::pair<const int, int> >::type&)'
   22 |    if (not count(k)) ret += magic((double) v / o.tot);
      |            ~~~~~^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from lang.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:4077:5: note: candidate: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4077 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
/usr/include/c++/10/bits/stl_algo.h:4077:5: note:   template argument deduction/substitution failed:
lang.cpp:22:17: note:   candidate expects 3 arguments, 1 provided
   22 |    if (not count(k)) ret += magic((double) v / o.tot);
      |            ~~~~~^~~
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from lang.cpp:3:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:101:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:101:1: note:   template argument deduction/substitution failed:
lang.cpp:22:17: note:   candidate expects 4 arguments, 1 provided
   22 |    if (not count(k)) ret += magic((double) v / o.tot);
      |            ~~~~~^~~