Submission #668139

#TimeUsernameProblemLanguageResultExecution timeMemory
668139definitelynotmeeTable Tennis (info1cup20_tabletennis)C++98
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define all(x) x.begin(), x.end() using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<typename T> using matrix = vector<vector<T>>; struct hashzao{ int operator()(int i){ return i^981723478; } }; int main(){ cin.tie(0)->sync_with_stdio(0); int n, k; cin >> n >> k; vector<int> v(n+k); for(int i = 0; i < n+k; i++) cin >> v[i]; unordered_map<int,int,hashzao> sums; int minmid = max(0,(n+k)/2-k/2-3), maxmid = min(n+k-1,(n+k)/2+k/2+3); for(int offset = -k; offset <= k; offset++){ for(int i = 0; i < n+k; i++){ int y = n+k-i-1; y+=offset; if(y >= 0 && y < n+k) sums[v[i]+v[y]]++; } } auto findans =[&](int sum){ int p1 = 0, p2 = n+k-1; vector<int> resp; while(p1 < p2){ if(v[p1] + v[p2] > sum){ p2--; continue; } if(v[p1] + v[p2] < sum){ p1++; continue; } resp.push_back(v[p1]), resp.push_back(v[p2]); p1++, p2--; } sort(all(resp)); for(int i = 0; i < n; i++) cout << resp[i] << ' '; cout << '\n'; }; // for(pii i : sums) // cout << i.ff << ' ' << i.ss << '\n'; for(pii i : sums){ if(i.ss < n) continue; int sum = i.ff; int resp = 0; int p1 = 0, p2 = n+k-1; while(p1 < p2){ if(v[p1] + v[p2] > sum){ p2--; continue; } if(v[p1] + v[p2] < sum){ p1++; continue; } p1++, p2--; resp++; } //cout << sum << ' ' << resp << '\n'; if(resp >= n/2){ findans(sum); return 0; } } //exit(1); }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:31:9: warning: unused variable 'minmid' [-Wunused-variable]
   31 |     int minmid = max(0,(n+k)/2-k/2-3), maxmid = min(n+k-1,(n+k)/2+k/2+3);
      |         ^~~~~~
tabletennis.cpp:31:40: warning: unused variable 'maxmid' [-Wunused-variable]
   31 |     int minmid = max(0,(n+k)/2-k/2-3), maxmid = min(n+k-1,(n+k)/2+k/2+3);
      |                                        ^~~~~~
In file included from /usr/include/c++/10/bits/hashtable.h:35,
                 from /usr/include/c++/10/unordered_map:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:117,
                 from tabletennis.cpp:1:
/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 = int; _Value = std::pair<const int, int>; _ExtractKey = std::__detail::_Select1st; _H1 = hashzao; _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 = int; _Pair = std::pair<const int, int>; _Alloc = std::allocator<std::pair<const int, int> >; _Equal = std::equal_to<int>; _H1 = hashzao; _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 = 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 = int; _Tp = int; _Hash = hashzao; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int]'
tabletennis.cpp:38:31:   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 hashzao) (const int&)'
 1379 |  return _M_h1()(__k);
      |         ~~~~~~~^~~~~
tabletennis.cpp:13:9: note: candidate: 'int hashzao::operator()(int)' (near match)
   13 |     int operator()(int i){
      |         ^~~~~~~~
tabletennis.cpp:13:9: note:   passing 'const hashzao*' as 'this' argument discards qualifiers