# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
915028 | Cabralbonzao | Race (IOI11_race) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#include "race.h"
using namespace std;
#define N 200002
#define INF 1000000020
#define INFLL 1000000000000000020
#define fi first
#define se second
#define pb push_back
#define LOG 18
#define SQRT 25
typedef long int ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef vector< ll > vl;
typedef vector< pll > vll;
typedef tuple< int, int, int> tiii;
typedef tuple< ll, ll, ll> tlll;
vector<ll>*vet[N];
ll ans=N*INF;
ll k;
ll sz[N];
ll lvl[N];
ll sum[N];
vector<ll>grafo[N];
map<pll,ll>qtd;
map<pll,ll> :: iterator it;
unordered_map<pll,ll>peso;
unordered_map<ll,bool>has;
void Verify(ll val)
{
if(!has[val])
{
has[val]=true;
qtd[{val,INFLL}]++;
}
return;
}
void ADD(ll val,ll nivel)
{
Verify(val);
qtd[{val,nivel}]++;
return;
}
void REMOVE(ll val,ll nivel)
{
qtd[{val,nivel}]--;
if(!qtd[{val,nivel}])
{
qtd.erase({val,nivel});
}
return;
}
void build(ll u,ll p)
{
sz[u]=1;
ll w;
for(auto v : grafo[u])
{
if(v==p)
continue;
w=peso[{u,v}];
lvl[v]=lvl[u]+1LL;
sum[v]=sum[u]+w;
build(v,u);
sz[u]+=sz[v];
}
return;
}
void DFS(ll u,ll p,bool keep)
{
ll mx=-1,big;
for(auto v : grafo[u])
{
if(v==p)
continue;
if(mx<sz[v])
{
mx=sz[v];
big=v;
}
}
for(auto v : grafo[u])
{
if(v==p || v==big)
continue;
DFS(v,u,false);
}
if(mx!=-1)
{
DFS(big,u,true);
vet[u]=vet[big];
}else
{
vet[u]=new vector<ll>();
}
ll K=k+2*sum[u];
(*vet[u]).pb(u);
ADD(sum[u],lvl[u]);
for(auto v : grafo[u])
{
if(v==p || v==big)
continue;
for(auto x : (*vet[v]))
{
Verify(K-sum[x]);
it=qtd.lower_bound({K-sum[x],0LL});
ans=min(ans,lvl[x]+
(*it).first.second-
2*lvl[u]);
}
for(auto x : (*vet[v]))
{
(*vet[u]).pb(x);
ADD(sum[x],lvl[x]);
}
}
Verify(k+sum[u]);
it=qtd.lower_bound({k+sum[u],0LL});
ans=min(ans,(*it).first.second-lvl[u]);
if(!keep)
{
for(auto x : (*vet[u]))
{
REMOVE(sum[x],lvl[x]);
}
}
return;
}
int best_path(int n, int K, int H[][2], int L[])
{
ll i=0,u,v,w;
k=K;
while(i<n-1)
{
u=H[i][0];
v=H[i][1];
grafo[u].pb(v);
grafo[v].pb(u);
peso[{u,v}]=peso[{v,u}]=L[i];
i++;
}
lvl[0]=1;
build(0,0);
DFS(0,0,true);
if(ans>n)
ans=-1;
return ans;
}
Compilation message (stderr)
race.cpp:23:9: warning: integer overflow in expression of type 'int' results in '-1738072792' [-Woverflow] 23 | ll ans=N*INF; | ^ race.cpp:31:22: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long int, long int>; _Tp = long int; _Hash = std::hash<std::pair<long int, long int> >; _Pred = std::equal_to<std::pair<long int, long int> >; _Alloc = std::allocator<std::pair<const std::pair<long int, long int>, long int> >]' 31 | unordered_map<pll,ll>peso; | ^~~~ In file included from /usr/include/c++/10/unordered_map:47, 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 race.cpp:1: /usr/include/c++/10/bits/unordered_map.h:141:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long int, long int>; _Tp = long int; _Hash = std::hash<std::pair<long int, long int> >; _Pred = std::equal_to<std::pair<long int, long int> >; _Alloc = std::allocator<std::pair<const std::pair<long int, long int>, long int> >]' is implicitly deleted because the default definition would be ill-formed: 141 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/10/bits/unordered_map.h:141:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long int, long int>; _Value = std::pair<const std::pair<long int, long int>, long int>; _Alloc = std::allocator<std::pair<const std::pair<long int, long int>, long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long int, long int> >; _H1 = std::hash<std::pair<long int, long int> >; _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>]' In file included 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 race.cpp:1: /usr/include/c++/10/bits/hashtable.h:451:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long int, long int>; _Value = std::pair<const std::pair<long int, long int>, long int>; _Alloc = std::allocator<std::pair<const std::pair<long int, long int>, long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long int, long int> >; _H1 = std::hash<std::pair<long int, long int> >; _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>]' is implicitly deleted because the default definition would be ill-formed: 451 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/10/bits/hashtable.h:451:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, _Traits>::_Hashtable_base() [with _Key = std::pair<long int, long int>; _Value = std::pair<const std::pair<long int, long int>, long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long int, long int> >; _H1 = std::hash<std::pair<long int, long int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' 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 race.cpp:1: /usr/include/c++/10/bits/hashtable_policy.h:1791:5: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, _Traits>::_Hashtable_base() [with _Key = std::pair<long int, long int>; _Value = std::pair<const std::pair<long int, long int>, long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long int, long int> >; _H1 = std::hash<std::pair<long int, long int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1791 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1791:5: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::_Hash_code_base() [with _Key = std::pair<long int, long int>; _Value = std::pair<const std::pair<long int, long int>, long int>; _ExtractKey = std::__detail::_Select1st; _H1 = std::hash<std::pair<long int, long int> >; _H2 = std::__detail::_Mod_range_hashing]' /usr/include/c++/10/bits/hashtable_policy.h:1368:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::_Hash_code_base() [with _Key = std::pair<long int, long int>; _Value = std::pair<const std::pair<long int, long int>, long int>; _ExtractKey = std::__detail::_Select1st; _H1 = std::hash<std::pair<long int, long int> >; _H2 = std::__detail::_Mod_range_hashing]' is implicitly deleted because the default definition would be ill-formed: 1368 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1368:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<long int, long int> >]' /usr/include/c++/10/bits/hashtable_policy.h:1112:7: note: 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<long int, long int> >]' is implicitly deleted because the default definition would be ill-formed: 1112 | _Hashtable_ebo_helper() = default; | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1112:7: error: use of deleted function 'std::hash<std::pair<long int, long int> >::hash()' In file included from /usr/include/c++/10/string_view:42, from /usr/include/c++/10/bits/basic_string.h:48, from /usr/include/c++/10/string:55, 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 race.cpp:1: /usr/include/c++/10/bits/functional_hash.h:101:12: note: 'std::hash<std::pair<long int, long int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 101 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/10/bits/functional_hash.h:101:12: error: no matching function for call to 'std::__hash_enum<std::pair<long int, long int>, false>::__hash_enum()' /usr/include/c++/10/bits/functional_hash.h:82:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<long int, long int>; bool <anonymous> = false]' 82 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/10/bits/functional_hash.h:82:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/10/bits/functional_hash.h:101:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long int, long int>; bool <anonymous> = false]' is private within this context 101 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/10/bits/functional_hash.h:83:7: note: declared private here 83 | ~__hash_enum(); | ^ 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 race.cpp:1: /usr/include/c++/10/bits/hashtable_policy.h:1112:7: error: use of deleted function 'std::hash<std::pair<long int, long int> >::~hash()' 1112 | _Hashtable_ebo_helper() = default; | ^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/string_view:42, from /usr/include/c++/10/bits/basic_string.h:48, from /usr/include/c++/10/string:55, 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 race.cpp:1: /usr/include/c++/10/bits/functional_hash.h:101:12: note: 'std::hash<std::pair<long int, long int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 101 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/10/bits/functional_hash.h:101:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long int, long int>; bool <anonymous> = false]' is private within this context /usr/include/c++/10/bits/functional_hash.h:83:7: note: declared private here 83 | ~__hash_enum(); | ^ 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 race.cpp:1: /usr/include/c++/10/bits/hashtable_policy.h:1368:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long int, long int> >, true>::~_Hashtable_ebo_helper()' 1368 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1109:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long int, long int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1109 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1109:12: error: use of deleted function 'std::hash<std::pair<long int, long int> >::~hash()' /usr/include/c++/10/bits/hashtable_policy.h:1791:5: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<long int, long int>, std::pair<const std::pair<long int, long int>, long int>, std::__detail::_Select1st, std::hash<std::pair<long int, long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' 1791 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1341:12: note: 'std::__detail::_Hash_code_base<std::pair<long int, long int>, std::pair<const std::pair<long int, long int>, long int>, std::__detail::_Select1st, std::hash<std::pair<long int, long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1341 | struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1342 | _Default_ranged_hash, true> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1341:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long int, long int> >, true>::~_Hashtable_ebo_helper()' In file included 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 race.cpp:1: /usr/include/c++/10/bits/hashtable.h:451:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<long int, long int>, std::pair<const std::pair<long int, long int>, long int>, std::__detail::_Select1st, std::equal_to<std::pair<long int, long int> >, std::hash<std::pair<long int, long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()' 451 | _Hashtable() = default; | ^~~~~~~~~~ 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 race.cpp:1: /usr/include/c++/10/bits/hashtable_policy.h:1725:10: note: 'std::__detail::_Hashtable_base<std::pair<long int, long int>, std::pair<const std::pair<long int, long int>, long int>, std::__detail::_Select1st, std::equal_to<std::pair<long int, long int> >, std::hash<std::pair<long int, long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()' is implicitly deleted because the default definition would be ill-formed: 1725 | struct _Hashtable_base | ^~~~~~~~~~~~~~~ /usr/include/c++/10/bits/hashtable_policy.h:1725:10: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<long int, long int>, std::pair<const std::pair<long int, long int>, long int>, std::__detail::_Select1st, std::hash<std::pair<long int, long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' race.cpp: In function 'int best_path(int, int, int (*)[2], int*)': race.cpp:141:13: warning: unused variable 'w' [-Wunused-variable] 141 | ll i=0,u,v,w; | ^ 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 race.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 = std::pair<long int, long int>; _Value = std::pair<const std::pair<long int, long int>, long int>; _ExtractKey = std::__detail::_Select1st; _H1 = std::hash<std::pair<long int, long int> >; _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<long int, long int>; _Pair = std::pair<const std::pair<long int, long int>, long int>; _Alloc = std::allocator<std::pair<const std::pair<long int, long int>, long int> >; _Equal = std::equal_to<std::pair<long int, long int> >; _H1 = std::hash<std::pair<long int, long int> >; _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 = long int; std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::key_type = std::pair<long int, long 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<long int, long int>; _Tp = long int; _Hash = std::hash<std::pair<long int, long int> >; _Pred = std::equal_to<std::pair<long int, long int> >; _Alloc = std::allocator<std::pair<const std::pair<long int, long int>, long int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = long int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = std::pair<long int, long int>]' race.cpp:69:15: 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 std::hash<std::pair<long int, long int> >) (const std::pair<long int, long int>&)' 1379 | return _M_h1()(__k); | ~~~~~~~^~~~~ In file included 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,