# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1011443 | 2024-06-30T13:48:08 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 / tot - (o.m.count(k) ? (double) o.m.at(k) / o.tot : 0)); } for (auto [k, v]: o.m) { 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 member function 'void Data<T, Hash, MAX>::operator+=(const Data<T, Hash, MAX>&)': lang.cpp:32:24: error: expected unqualified-id before ')' token 32 | for (auto &[k, v]: o.) { | ^ 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: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:26:14: 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 'contains' lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = std::array<int, 3>; Hash = hash3; int MAX = 50]': lang.cpp:74:56: required from here lang.cpp:26:14: error: 'const class std::unordered_map<std::array<int, 3>, int, hash3, std::equal_to<std::array<int, 3> >, std::allocator<std::pair<const std::array<int, 3>, int> > >' has no member named 'contains' lang.cpp: In instantiation of 'void Data<T, Hash, MAX>::operator+=(const Data<T, Hash, MAX>&) [with T = int; Hash = std::hash<int>; int MAX = 50]': lang.cpp:78:17: required from here lang.cpp:33:24: error: use of 'k' before deduction of 'auto' 33 | inv.erase({m[k], k}); | ^ lang.cpp:33:20: error: no matching function for call to 'std::set<std::pair<int, int>, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::erase(<brace-enclosed initializer list>)' 33 | inv.erase({m[k], k}); | ~~~~~~~~~^~~~~~~~~~~ In file included from /usr/include/c++/10/set:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from lang.cpp:3: /usr/include/c++/10/bits/stl_set.h:654:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]' 654 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:654:28: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int>, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} 654 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/10/bits/stl_set.h:684:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]' 684 | erase(const key_type& __x) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:684:29: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'} 684 | erase(const key_type& __x) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]' 706 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate expects 2 arguments, 1 provided lang.cpp:34:24: error: use of 'v' before deduction of 'auto' 34 | inv.emplace(m[k] += v, k); | ^ lang.cpp: In instantiation of 'void Data<T, Hash, MAX>::operator+=(const Data<T, Hash, MAX>&) [with T = std::pair<int, int>; Hash = hash2; int MAX = 50]': lang.cpp:79:11: required from here lang.cpp:33:24: error: use of 'k' before deduction of 'auto' 33 | inv.erase({m[k], k}); | ^ lang.cpp:33:20: error: no matching function for call to 'std::set<std::pair<int, std::pair<int, int> >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::erase(<brace-enclosed initializer list>)' 33 | inv.erase({m[k], k}); | ~~~~~~~~~^~~~~~~~~~~ In file included from /usr/include/c++/10/set:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from lang.cpp:3: /usr/include/c++/10/bits/stl_set.h:654:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, std::pair<int, int> >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator]' 654 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:654:28: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, std::pair<int, int> >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator' {aka 'std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator'} 654 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/10/bits/stl_set.h:684:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<int, std::pair<int, int> >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, std::pair<int, int> >]' 684 | erase(const key_type& __x) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:684:29: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, std::pair<int, int> >&'} 684 | erase(const key_type& __x) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, std::pair<int, int> >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator]' 706 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate expects 2 arguments, 1 provided lang.cpp:34:24: error: use of 'v' before deduction of 'auto' 34 | inv.emplace(m[k] += v, k); | ^ lang.cpp: In instantiation of 'void Data<T, Hash, MAX>::operator+=(const Data<T, Hash, MAX>&) [with T = std::array<int, 3>; Hash = hash3; int MAX = 50]': lang.cpp:80:17: required from here lang.cpp:33:24: error: use of 'k' before deduction of 'auto' 33 | inv.erase({m[k], k}); | ^ lang.cpp:33:20: error: no matching function for call to 'std::set<std::pair<int, std::array<int, 3> >, std::less<std::pair<int, std::array<int, 3> > >, std::allocator<std::pair<int, std::array<int, 3> > > >::erase(<brace-enclosed initializer list>)' 33 | inv.erase({m[k], k}); | ~~~~~~~~~^~~~~~~~~~~ In file included from /usr/include/c++/10/set:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from lang.cpp:3: /usr/include/c++/10/bits/stl_set.h:654:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, std::array<int, 3> >; _Compare = std::less<std::pair<int, std::array<int, 3> > >; _Alloc = std::allocator<std::pair<int, std::array<int, 3> > >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, std::array<int, 3> >, std::pair<int, std::array<int, 3> >, std::_Identity<std::pair<int, std::array<int, 3> > >, std::less<std::pair<int, std::array<int, 3> > >, std::allocator<std::pair<int, std::array<int, 3> > > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, std::array<int, 3> >, std::pair<int, std::array<int, 3> >, std::_Identity<std::pair<int, std::array<int, 3> > >, std::less<std::pair<int, std::array<int, 3> > >, std::allocator<std::pair<int, std::array<int, 3> > > >::const_iterator]' 654 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:654:28: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, std::array<int, 3> >, std::less<std::pair<int, std::array<int, 3> > >, std::allocator<std::pair<int, std::array<int, 3> > > >::const_iterator' {aka 'std::_Rb_tree<std::pair<int, std::array<int, 3> >, std::pair<int, std::array<int, 3> >, std::_Identity<std::pair<int, std::array<int, 3> > >, std::less<std::pair<int, std::array<int, 3> > >, std::allocator<std::pair<int, std::array<int, 3> > > >::const_iterator'} 654 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/10/bits/stl_set.h:684:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<int, std::array<int, 3> >; _Compare = std::less<std::pair<int, std::array<int, 3> > >; _Alloc = std::allocator<std::pair<int, std::array<int, 3> > >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, std::array<int, 3> >]' 684 | erase(const key_type& __x) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:684:29: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, std::array<int, 3> >&'} 684 | erase(const key_type& __x) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, std::array<int, 3> >; _Compare = std::less<std::pair<int, std::array<int, 3> > >; _Alloc = std::allocator<std::pair<int, std::array<int, 3> > >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, std::array<int, 3> >, std::pair<int, std::array<int, 3> >, std::_Identity<std::pair<int, std::array<int, 3> > >, std::less<std::pair<int, std::array<int, 3> > >, std::allocator<std::pair<int, std::array<int, 3> > > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, std::array<int, 3> >, std::pair<int, std::array<int, 3> >, std::_Identity<std::pair<int, std::array<int, 3> > >, std::less<std::pair<int, std::array<int, 3> > >, std::allocator<std::pair<int, std::array<int, 3> > > >::const_iterator]' 706 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate expects 2 arguments, 1 provided lang.cpp:34:24: error: use of 'v' before deduction of 'auto' 34 | inv.emplace(m[k] += v, k); | ^ In file included from /usr/include/c++/10/bits/hashtable.h:35, from /usr/include/c++/10/unordered_map:46, from /usr/include/c++/10/functional:61, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, 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/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::__hash_code std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::_M_hash_code(const _Key&) const [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _H1 = hash2; _H2 = std::__detail::_Mod_range_hashing; std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::__hash_code = long unsigned int]': /usr/include/c++/10/bits/hashtable_policy.h:734:45: required from 'std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::mapped_type& std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::operator[](std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::key_type&&) [with _Key = std::pair<int, int>; _Pair = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _Equal = std::equal_to<std::pair<int, int> >; _H1 = hash2; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>; std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::mapped_type = int; std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::key_type = std::pair<int, int>]' /usr/include/c++/10/bits/unordered_map.h:988:20: required from 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Hash = hash2; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = std::pair<int, int>]' lang.cpp:61:45: required from here /usr/include/c++/10/bits/hashtable_policy.h:1377:16: error: static assertion failed: hash function must be invocable with an argument of key type 1377 | static_assert(__is_invocable<const _H1&, const _Key&>{}, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1379:16: error: no match for call to '(const hash2) (const std::pair<int, int>&)' 1379 | return _M_h1()(__k); | ~~~~~~~^~~~~ lang.cpp:45:4: note: candidate: 'll hash2::operator()(const pint&)' (near match) 45 | ll operator() (const pint &x) { return (ll) x.first << 16 | x.second; } | ^~~~~~~~ lang.cpp:45:4: note: passing 'const hash2*' as 'this' argument discards qualifiers In file included from /usr/include/c++/10/bits/hashtable.h:35, from /usr/include/c++/10/unordered_map:46, from /usr/include/c++/10/functional:61, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c+