# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1011440 | 2024-06-30T13:46:28 Z | Double_Slash | Languages (IOI10_languages) | C++17 | Compilation error |
0 ms | 0 KB |
#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; }() using ll = long long; using pint = pair<int, int>; double magic(double x) { return abs(x); } template <typename T, class Hash, int MAX> struct Data { int tot = 0; unordered_map<T, int, Hash> m; set<pair<int, T>> inv; double operator&(const Data<T, Hash, MAX> &o) const { double ret = 0; for (auto [k, v]: m) { ret += magic((double) v / m.tot - (o.count(k) ? (double) o.at(k) / o.tot : 0)); } for (auto [k, v]: o) { if (not m.contains(k)) ret += magic((double) v / o.tot); } return ret; } void operator+=(const Data<T, Hash, MAX> &o) { for (auto &[k, v]: o) { inv.erase({m[k], k}); inv.emplace(m[k] += v, k); } tot += o.tot; while (inv.size() > MAX) { tot -= inv.begin()->first; m.erase(inv.begin()->second); inv.erase(inv.begin()); } }}; struct hash2 { ll operator() (const pint &x) { return (ll) x.first << 16 | x.second; } }; struct hash3 { ll operator()(const array<int, 3> &x) { return ((ll) x[0] << 32) | ((ll) x[1] << 16) | x[2]; } }; struct Profile { Data<int, hash<int>, 50> sing; Data<pint, hash2, 50> doub; Data<array<int, 3>, hash3, 50> trip; Profile() {} Profile(int *arr) { for (int i = 0; i < 100; ++i) { sing.m[arr[i]]++; if (i) doub.m[{arr[i - 1], arr[i]}]++; if (i >=2) trip.m[{arr[i - 2], arr[i - 1], arr[i]}]; } for (auto [k, v]: sing.m) sing.inv.emplace(v, k); for (auto [k, v]: doub.m) doub.inv.emplace(v, k); for (auto [k, v]: trip.m) trip.inv.emplace(v, k); sing.tot = 100; doub.tot = 99; trip.tot = 98; } double operator&(const Profile &o) const { return (sing & o.sing) + (doub & o.doub) + (trip & o.trip); } void operator+=(const Profile &o) { sing += o.sing; doub += o.doub; trip += o.trip; } } 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
lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]': lang.cpp:74:20: required from here lang.cpp:23:32: error: 'const class std::unordered_map<int, int>' has no member named 'tot' 23 | ret += magic((double) v / m.tot - (o.count(k) ? (double) o.at(k) / o.tot : 0)); | ~~^~~ lang.cpp:23:41: error: 'const struct Data<int, std::hash<int>, 50>' has no member named 'count' 23 | ret += magic((double) v / m.tot - (o.count(k) ? (double) o.at(k) / o.tot : 0)); | ~~^~~~~ lang.cpp:23:63: error: 'const struct Data<int, std::hash<int>, 50>' has no member named 'at' 23 | ret += magic((double) v / m.tot - (o.count(k) ? (double) o.at(k) / o.tot : 0)); | ~~^~ lang.cpp:25:3: error: no matching function for call to 'begin(const Data<int, std::hash<int>, 50>&)' 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/c++/10/bits/range_access.h:36, from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from lang.cpp:3: /usr/include/c++/10/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)' 90 | begin(initializer_list<_Tp> __ils) noexcept | ^~~~~ /usr/include/c++/10/initializer_list:90:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: 'Data<int, std::hash<int>, 50>' is not derived from 'std::initializer_list<_Tp>' 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from lang.cpp:3: /usr/include/c++/10/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)' 51 | begin(_Container& __cont) -> decltype(__cont.begin()) | ^~~~~ /usr/include/c++/10/bits/range_access.h:51:5: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = const Data<int, std::hash<int>, 50>]': lang.cpp:25:3: required from 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]' lang.cpp:74:20: required from here /usr/include/c++/10/bits/range_access.h:51:50: error: 'const struct Data<int, std::hash<int>, 50>' has no member named 'begin' 51 | begin(_Container& __cont) -> decltype(__cont.begin()) | ~~~~~~~^~~~~ lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]': lang.cpp:74:20: required from here /usr/include/c++/10/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)' 61 | begin(const _Container& __cont) -> decltype(__cont.begin()) | ^~~~~ /usr/include/c++/10/bits/range_access.h:61:5: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = Data<int, std::hash<int>, 50>]': lang.cpp:25:3: required from 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]' lang.cpp:74:20: required from here /usr/include/c++/10/bits/range_access.h:61:56: error: 'const struct Data<int, std::hash<int>, 50>' has no member named 'begin' 61 | begin(const _Container& __cont) -> decltype(__cont.begin()) | ~~~~~~~^~~~~ lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]': lang.cpp:74:20: required from here /usr/include/c++/10/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])' 90 | begin(_Tp (&__arr)[_Nm]) | ^~~~~ /usr/include/c++/10/bits/range_access.h:90:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: mismatched types '_Tp [_Nm]' and 'const Data<int, std::hash<int>, 50>' 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95, from lang.cpp:3: /usr/include/c++/10/valarray:1214:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)' 1214 | begin(valarray<_Tp>& __va) | ^~~~~ /usr/include/c++/10/valarray:1214:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: types 'std::valarray<_Tp>' and 'const Data<int, std::hash<int>, 50>' have incompatible cv-qualifiers 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95, from lang.cpp:3: /usr/include/c++/10/valarray:1224:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)' 1224 | begin(const valarray<_Tp>& __va) | ^~~~~ /usr/include/c++/10/valarray:1224:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: 'const Data<int, std::hash<int>, 50>' is not derived from 'const std::valarray<_Tp>' 25 | for (auto [k, v]: o) { | ^~~ lang.cpp:25:3: error: no matching function for call to 'end(const Data<int, std::hash<int>, 50>&)' In file included from /usr/include/c++/10/bits/range_access.h:36, from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from lang.cpp:3: /usr/include/c++/10/initializer_list:101:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)' 101 | end(initializer_list<_Tp> __ils) noexcept | ^~~ /usr/include/c++/10/initializer_list:101:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: 'Data<int, std::hash<int>, 50>' is not derived from 'std::initializer_list<_Tp>' 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from lang.cpp:3: /usr/include/c++/10/bits/range_access.h:71:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 71 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/10/bits/range_access.h:71:5: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = const Data<int, std::hash<int>, 50>]': lang.cpp:25:3: required from 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]' lang.cpp:74:20: required from here /usr/include/c++/10/bits/range_access.h:71:48: error: 'const struct Data<int, std::hash<int>, 50>' has no member named 'end' 71 | end(_Container& __cont) -> decltype(__cont.end()) | ~~~~~~~^~~ lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]': lang.cpp:74:20: required from here /usr/include/c++/10/bits/range_access.h:81:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 81 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/10/bits/range_access.h:81:5: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = Data<int, std::hash<int>, 50>]': lang.cpp:25:3: required from 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]' lang.cpp:74:20: required from here /usr/include/c++/10/bits/range_access.h:81:54: error: 'const struct Data<int, std::hash<int>, 50>' has no member named 'end' 81 | end(const _Container& __cont) -> decltype(__cont.end()) | ~~~~~~~^~~ lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 50]': lang.cpp:74:20: required from here /usr/include/c++/10/bits/range_access.h:100:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 100 | end(_Tp (&__arr)[_Nm]) | ^~~ /usr/include/c++/10/bits/range_access.h:100:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: mismatched types '_Tp [_Nm]' and 'const Data<int, std::hash<int>, 50>' 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95, from lang.cpp:3: /usr/include/c++/10/valarray:1234:5: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)' 1234 | end(valarray<_Tp>& __va) | ^~~ /usr/include/c++/10/valarray:1234:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: types 'std::valarray<_Tp>' and 'const Data<int, std::hash<int>, 50>' have incompatible cv-qualifiers 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95, from lang.cpp:3: /usr/include/c++/10/valarray:1244:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)' 1244 | end(const valarray<_Tp>& __va) | ^~~ /usr/include/c++/10/valarray:1244:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: 'const Data<int, std::hash<int>, 50>' is not derived from 'const std::valarray<_Tp>' 25 | for (auto [k, v]: o) { | ^~~ lang.cpp:26:14: error: 'const class std::unordered_map<int, int>' has no member named 'contains' 26 | if (not m.contains(k)) ret += magic((double) v / o.tot); | ~~^~~~~~~~ lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = std::pair<int, int>; Hash = hash2; int MAX = 50]': lang.cpp:74:38: required from here lang.cpp:23:32: error: 'const class std::unordered_map<std::pair<int, int>, int, hash2, std::equal_to<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >' has no member named 'tot' 23 | ret += magic((double) v / m.tot - (o.count(k) ? (double) o.at(k) / o.tot : 0)); | ~~^~~ lang.cpp:23:41: error: 'const struct Data<std::pair<int, int>, hash2, 50>' has no member named 'count' 23 | ret += magic((double) v / m.tot - (o.count(k) ? (double) o.at(k) / o.tot : 0)); | ~~^~~~~ lang.cpp:23:63: error: 'const struct Data<std::pair<int, int>, hash2, 50>' has no member named 'at' 23 | ret += magic((double) v / m.tot - (o.count(k) ? (double) o.at(k) / o.tot : 0)); | ~~^~ lang.cpp:25:3: error: no matching function for call to 'begin(const Data<std::pair<int, int>, hash2, 50>&)' 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/c++/10/bits/range_access.h:36, from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from lang.cpp:3: /usr/include/c++/10/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)' 90 | begin(initializer_list<_Tp> __ils) noexcept | ^~~~~ /usr/include/c++/10/initializer_list:90:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: 'Data<std::pair<int, int>, hash2, 50>' is not derived from 'std::initializer_list<_Tp>' 25 | for (auto [k, v]: o) { | ^~~ In file included from /usr/include/c++/10/string:54, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from lang.cpp:3: /usr/include/c++/10/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)' 51 | begin(_Container& __cont) -> decltype(__cont.begin()) | ^~~~~ /usr/include/c++/10/bits/range_access.h:51:5: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = const Data<std::pair<int, int>, hash2, 50>]': lang.cpp:25:3: required from 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = std::pair<int, int>; Hash = hash2; int MAX = 50]' lang.cpp:74:38: required from here /usr/include/c++/10/bits/range_access.h:51:50: error: 'const struct Data<std::pair<int, int>, hash2, 50>' has no member named 'begin' 51 | begin(_Container& __cont) -> decltype(__cont.begin()) | ~~~~~~~^~~~~ lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = std::pair<int, int>; Hash = hash2; int MAX = 50]': lang.cpp:74:38: required from here /usr/include/c++/10/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)' 61 | begin(const _Container& __cont) -> decltype(__cont.begin()) | ^~~~~ /usr/include/c++/10/bits/range_access.h:61:5: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = Data<std::pair<int, int>, hash2, 50>]': lang.cpp:25:3: required from 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = std::pair<int, int>; Hash = hash2; int MAX = 50]' lang.cpp:74:38: required from here /usr/include/c++/10/bits/range_access.h:61:56: error: 'const struct Data<std::pair<int, int>, hash2, 50>' has no member named 'begin' 61 | begin(const _Container& __cont) -> decltype(__cont.begin()) | ~~~~~~~^~~~~ lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = std::pair<int, int>; Hash = hash2; int MAX = 50]': lang.cpp:74:38: required from here /usr/include/c++/10/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])' 90 | begin(_Tp (&__arr)[_Nm]) | ^~~~~ /usr/include/c++/10/bits/range_access.h:90:5: note: template argument deduction/substitution failed: lang.cpp:25:3: note: mismatched types '_T