| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 290111 | REALITYNB | Race (IOI11_race) | C++14 | 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"
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
int n , k ;
const int mxn = 2e5+1 ;
vector<pii> adj[mxn] ;
vector<int> sz(mxn) , w(mxn) ,h(mxn) ;
void sub(int a , int p){
sz[a]=1 ;
if(p!=-1) h[a]=h[p]+1 ;
for(pii& x : adj[a]){
if(x.F==p) continue ;
w[x.F]=w[a]+x.S ;
sub(x.F,a) ;
sz[a]+=sz[x.F] ;
}
}
int mn = 1e9 ;
vector<int> p[mxn] ;
map<int,multiset<int>> cnt ;
void dfs(int a , int pp , int keep){
int bigchild = -1 , mx = -1 ;
for(pii& y : adj[a]){
int x = y.F ;
if(x==pp) continue ;
if(sz[x]>mx){
mx=sz[x] ;
bigchild= x ;
}
}
for(pii& y : adj[a]){
int x = y.F ;
if(x==pp||x==bigchild) continue ;
dfs(x,a,0) ;
}
if(bigchild!=-1){
dfs(bigchild,a,1) ;
swap(p[bigchild],swap(p[a])) ;
// p[bigchild].swap(p[a]) ;
}
p[a].push_back(a) ;
int target = k+2*w[a] ;
if(cnt.count(target-w[a])) mn = min(mn,*(cnt[target-w[a]].begin())-h[a]) ;
cnt[w[a]].insert(h[a]) ;
for(pii& y : adj[a]){
if(y.F==pp||y.F==bigchild) continue ;
for(int& x : p[y.F]){
if(cnt.count(target-w[x])) mn = min(*(cnt[target-w[x]].begin())+h[x]-h[a]*2,mn) ;
p[a].pb(x) ;
}
for(int& x :p[y.F]) cnt[w[a]].insert(h[x]) ;
}
if(keep==0){
for(int& x: p[a]){
cnt[w[x]].erase(cnt[w[x]].find(h[x])) ;
if(cnt[w[x]].empty()) cnt.erase(cnt.find(w[x])) ;
}
}
}
int solve(){
sub(1,-1) ;
dfs(1,-1,1) ;
if(mn==1e9) return -1;
return mn ;
}
int best_path(int N , int K , int H[][2] , int L[]){
n = N ;
k = K ;
for(int i=0;i<n;i++){
adj[H[i][0]].push_back(mp(H[i][1],L[i]));
adj[H[i][1]].push_back(mp(H[i][0],L[i])) ;
}
return solve() ;
}
Compilation message (stderr)
race.cpp: In function 'void dfs(int, int, int)':
race.cpp:43:35: error: no matching function for call to 'swap(std::vector<int>&)'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from race.cpp:1:
/usr/include/c++/9/sstream:849:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&)'
849 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
| ^~~~
/usr/include/c++/9/sstream:849:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from race.cpp:1:
/usr/include/c++/9/sstream:856:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&)'
856 | swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
| ^~~~
/usr/include/c++/9/sstream:856:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from race.cpp:1:
/usr/include/c++/9/sstream:863:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&)'
863 | swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
| ^~~~
/usr/include/c++/9/sstream:863:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from race.cpp:1:
/usr/include/c++/9/sstream:870:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&)'
870 | swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
| ^~~~
/usr/include/c++/9/sstream:870:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/regex:62,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
from race.cpp:1:
/usr/include/c++/9/bits/regex.h:844:5: note: candidate: 'template<class _Ch_type, class _Rx_traits> void std::__cxx11::swap(std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&)'
844 | swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
| ^~~~
/usr/include/c++/9/bits/regex.h:844:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_regex<_Ch_type, _Rx_traits>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/regex:62,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
from race.cpp:1:
/usr/include/c++/9/bits/regex.h:2029:5: note: candidate: 'template<class _Bi_iter, class _Alloc> void std::__cxx11::swap(std::__cxx11::match_results<_BiIter, _Alloc>&, std::__cxx11::match_results<_BiIter, _Alloc>&)'
2029 | swap(match_results<_Bi_iter, _Alloc>& __lhs,
| ^~~~
/usr/include/c++/9/bits/regex.h:2029:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::__cxx11::match_results<_BiIter, _Alloc>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/bits/nested_exception.h:40,
from /usr/include/c++/9/exception:144,
from /usr/include/c++/9/ios:39,
from /usr/include/c++/9/istream:38,
from /usr/include/c++/9/sstream:38,
from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from race.cpp:1:
/usr/include/c++/9/bits/move.h:182:5: note: candidate: 'template<class _Tp> typename std::enable_if<std::__and_<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type std::swap(_Tp&, _Tp&)'
182 | swap(_Tp& __a, _Tp& __b)
| ^~~~
/usr/include/c++/9/bits/move.h:182:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: candidate expects 2 arguments, 1 provided
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/bits/nested_exception.h:40,
from /usr/include/c++/9/exception:144,
from /usr/include/c++/9/ios:39,
from /usr/include/c++/9/istream:38,
from /usr/include/c++/9/sstream:38,
from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from race.cpp:1:
/usr/include/c++/9/bits/move.h:205:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> typename std::enable_if<std::__is_swappable<_Tp>::value>::type std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
205 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
| ^~~~
/usr/include/c++/9/bits/move.h:205:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: mismatched types '_Tp [_Nm]' and 'std::vector<int>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
from /usr/include/c++/9/bits/char_traits.h:39,
from /usr/include/c++/9/ios:40,
from /usr/include/c++/9/istream:38,
from /usr/include/c++/9/sstream:38,
from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from race.cpp:1:
/usr/include/c++/9/bits/stl_pair.h:495:5: note: candidate: 'template<class _T1, class _T2> void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&)'
495 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
| ^~~~
/usr/include/c++/9/bits/stl_pair.h:495:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::pair<_T1, _T2>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/string:55,
from /usr/include/c++/9/bits/locale_classes.h:40,
from /usr/include/c++/9/bits/ios_base.h:41,
from /usr/include/c++/9/ios:42,
from /usr/include/c++/9/istream:38,
from /usr/include/c++/9/sstream:38,
from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from race.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6378:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
6378 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~
/usr/include/c++/9/bits/basic_string.h:6378:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/deque:67,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:68,
from race.cpp:1:
/usr/include/c++/9/bits/stl_deque.h:2366:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(std::deque<_Tp, _Alloc>&, std::deque<_Tp, _Alloc>&)'
2366 | swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
| ^~~~
/usr/include/c++/9/bits/stl_deque.h:2366:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::deque<_Tp, _Alloc>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:70,
from race.cpp:1:
/usr/include/c++/9/fstream:1264:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_filebuf<_CharT, _Traits>&, std::basic_filebuf<_CharT, _Traits>&)'
1264 | swap(basic_filebuf<_CharT, _Traits>& __x,
| ^~~~
/usr/include/c++/9/fstream:1264:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::basic_filebuf<_CharT, _Traits>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:70,
from race.cpp:1:
/usr/include/c++/9/fstream:1271:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_ifstream<_CharT, _Traits>&, std::basic_ifstream<_CharT, _Traits>&)'
1271 | swap(basic_ifstream<_CharT, _Traits>& __x,
| ^~~~
/usr/include/c++/9/fstream:1271:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::basic_ifstream<_CharT, _Traits>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:70,
from race.cpp:1:
/usr/include/c++/9/fstream:1278:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_ofstream<_CharT, _Traits>&, std::basic_ofstream<_CharT, _Traits>&)'
1278 | swap(basic_ofstream<_CharT, _Traits>& __x,
| ^~~~
/usr/include/c++/9/fstream:1278:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::basic_ofstream<_CharT, _Traits>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:70,
from race.cpp:1:
/usr/include/c++/9/fstream:1285:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_fstream<_CharT, _Traits>&, std::basic_fstream<_CharT, _Traits>&)'
1285 | swap(basic_fstream<_CharT, _Traits>& __x,
| ^~~~
/usr/include/c++/9/fstream:1285:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::basic_fstream<_CharT, _Traits>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/tuple:39,
from /usr/include/c++/9/functional:54,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:71,
from race.cpp:1:
/usr/include/c++/9/array:294:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> void std::swap(std::array<_Tp, _Nm>&, std::array<_Tp, _Nm>&)'
294 | swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
| ^~~~
/usr/include/c++/9/array:294:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::array<_Tp, _Nm>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/functional:54,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:71,
from race.cpp:1:
/usr/include/c++/9/tuple:1624:5: note: candidate: 'template<class ... _Elements> void std::swap(std::tuple<_Tps ...>&, std::tuple<_Tps ...>&)'
1624 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
| ^~~~
/usr/include/c++/9/tuple:1624:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::tuple<_Tps ...>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/functional:59,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:71,
from race.cpp:1:
/usr/include/c++/9/bits/std_function.h:785:5: note: candidate: 'template<class _Res, class ... _Args> void std::swap(std::function<_Res(_ArgTypes ...)>&, std::function<_Res(_ArgTypes ...)>&)'
785 | swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept
| ^~~~
/usr/include/c++/9/bits/std_function.h:785:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::function<_Res(_ArgTypes ...)>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/bits/locale_conv.h:41,
from /usr/include/c++/9/locale:43,
from /usr/include/c++/9/iomanip:43,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:72,
from race.cpp:1:
/usr/include/c++/9/bits/unique_ptr.h:701:5: note: candidate: 'template<class _Tp, class _Dp> void std::swap(std::unique_ptr<_Tp, _Dp>&, std::unique_ptr<_Tp, _Dp>&)'
701 | swap(unique_ptr<_Tp, _Dp>& __x,
| ^~~~
/usr/include/c++/9/bits/unique_ptr.h:701:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::unique_ptr<_Tp, _Dp>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/list:63,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:79,
from race.cpp:1:
/usr/include/c++/9/bits/stl_list.h:2056:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(std::__cxx11::list<_Tp, _Alloc>&, std::__cxx11::list<_Tp, _Alloc>&)'
2056 | swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
| ^~~~
/usr/include/c++/9/bits/stl_list.h:2056:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::__cxx11::list<_Tp, _Alloc>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/map:60,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
from race.cpp:1:
/usr/include/c++/9/bits/stl_tree.h:1649:5: note: candidate: 'template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> void std::swap(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)'
1649 | swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
| ^~~~
/usr/include/c++/9/bits/stl_tree.h:1649:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/map:61,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
from race.cpp:1:
/usr/include/c++/9/bits/stl_map.h:1507:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(std::map<_Key, _Tp, _Compare, _Alloc>&, std::map<_Key, _Tp, _Compare, _Alloc>&)'
1507 | swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
| ^~~~
/usr/include/c++/9/bits/stl_map.h:1507:5: note: template argument deduction/substitution failed:
race.cpp:43:35: note: 'std::vector<int>' is not derived from 'std::map<_Key, _Tp, _Compare, _Alloc>'
43 | swap(p[bigchild],swap(p[a])) ;
| ^
In file included from /usr/include/c++/9/map:62,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
from race.cpp:1:
/usr/include/c++/9/bits/stl_multimap.h:1171:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(std::multimap<_Key, _Tp, _Compare, _Alloc>&, std::multimap<_Key, _Tp, _Compare, _Alloc>&)'
1171 | swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
| ^~~~
/usr/include/c++/9/bits/stl_multimap.h:1171:5: note: template argument deduction/substitution failed:
/var/local/lib/i