Submission #1253697

#TimeUsernameProblemLanguageResultExecution timeMemory
1253697faricaFactories (JOI14_factories)C++20
Compilation error
0 ms0 KiB
#include "factories.h" #include<bits/stdc++.h> using namespace std; using vi = vector<int>; using pi = pair<int,int>; vector<pi>ancestors; vi sz; vector<bool>is_removed; vector<vector<pi>>adjL; int N2; int get_sz(int pos, int prev = -1) { sz[pos] = 1; for(pi adj: adjL[pos]) { if(adj.first == prev or is_removed[adj.first]) continue; sz[pos] += get_sz(adj.first, pos); } return sz[pos]; } int get_centroid(int pos, int n, int prev = -1) { for(pi adj: adjL[pos]) { if(adj.first == prev or is_removed[adj.first]) continue; if(sz[adj.first]*2 > n) return get_centroid(adj.first, n, pos); } return pos; } void get_dists(int pos, int centroid, int prev, int cur_dist) { for(pi adj: adjL[pos]) { if(adj.first == prev or is_removed[adj.first]) continue; get_dists(adj.first, centroid, pos, cur_dist + adj.second); } ancestors[pos].push_back({centroid, cur_dist}); } void build(int pos = 0) { int centroid = get_centroid(pos, get_sz(pos)); for(pi adj: adjL[centroid]) { if(is_removed[adj.first]) continue; get_dists(adj.first, centroid, centroid, adj.second); } is_removed[centroid] = 1; for(pi adj: adjL[centroid]) { if(is_removed[adj.first]) continue; build(adj.first); } } void Init(int N, int A[], int B[], int D[]) { N2 = N; adjL.assign(N, vi()); sz.assign(N, 0); for(int i=0; i<N-1; ++i) { adjL[a[i]].push_back({b[i], d[i]}); adjL[b[i]].push_back({a[i], d[i]}); } build(); } const ll MXVAL = 1e18; long long Query(int S, int X[], int T, int Y[]) { vector<ll> min_dist(N2, MXVAL); for(int i=0; i<S; ++i) { for(auto &[ancestor, dist]: ancestors[X[i]]) { min_dist[ancestor] = min(min_dist[ancestor], dist); } } ll ans = 0; for(int i=0; i<T; ++i) { ll cnt = MXVAL; for(auto &[ancestor, dist]: ancestors[Y[i]]) { if(min_dist[ancestor] == MXVAL) continue; cnt = min(cnt, dist + min_dist[ancestor]); } ans += cnt; } return ans; }

Compilation message (stderr)

factories.cpp: In function 'void get_dists(int, int, int, int)':
factories.cpp:35:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back'
   35 |     ancestors[pos].push_back({centroid, cur_dist});
      |                    ^~~~~~~~~
factories.cpp: In function 'void Init(int, int*, int*, int*)':
factories.cpp:53:16: error: no matching function for call to 'std::vector<std::vector<std::pair<int, int> > >::assign(int&, vi)'
   53 |     adjL.assign(N, vi());
      |     ~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from factories.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:768:9: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]'
  768 |         assign(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:768:9: note:   template argument deduction/substitution failed:
factories.cpp:53:16: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>')
   53 |     adjL.assign(N, vi());
      |     ~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from factories.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:749:47: note:   no known conversion for argument 2 from 'vi' {aka 'std::vector<int>'} to 'const value_type&' {aka 'const std::vector<std::pair<int, int> >&'}
  749 |       assign(size_type __n, const value_type& __val)
      |                             ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/11/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:794:7: note:   candidate expects 1 argument, 2 provided
factories.cpp:56:14: error: 'a' was not declared in this scope
   56 |         adjL[a[i]].push_back({b[i], d[i]});
      |              ^
factories.cpp:56:31: error: 'b' was not declared in this scope
   56 |         adjL[a[i]].push_back({b[i], d[i]});
      |                               ^
factories.cpp:56:37: error: 'd' was not declared in this scope
   56 |         adjL[a[i]].push_back({b[i], d[i]});
      |                                     ^
factories.cpp: At global scope:
factories.cpp:62:7: error: 'll' does not name a type
   62 | const ll MXVAL = 1e18;
      |       ^~
factories.cpp: In function 'long long int Query(int, int*, int, int*)':
factories.cpp:65:12: error: 'll' was not declared in this scope
   65 |     vector<ll> min_dist(N2, MXVAL);
      |            ^~
factories.cpp:65:14: error: template argument 1 is invalid
   65 |     vector<ll> min_dist(N2, MXVAL);
      |              ^
factories.cpp:65:14: error: template argument 2 is invalid
factories.cpp:65:29: error: 'MXVAL' was not declared in this scope
   65 |     vector<ll> min_dist(N2, MXVAL);
      |                             ^~~~~
factories.cpp:65:34: error: expression list treated as compound expression in initializer [-fpermissive]
   65 |     vector<ll> min_dist(N2, MXVAL);
      |                                  ^
factories.cpp:67:51: error: no matching function for call to 'begin(std::pair<int, int>&)'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
In file included from /usr/include/c++/11/bits/algorithmfwd.h:39,
                 from /usr/include/c++/11/bits/stl_algo.h:60,
                 from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from factories.cpp:2:
/usr/include/c++/11/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++/11/initializer_list:90:5: note:   template argument deduction/substitution failed:
factories.cpp:67:51: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from factories.cpp:2:
/usr/include/c++/11/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++/11/bits/range_access.h:51:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::pair<int, int>]':
factories.cpp:67:51:   required from here
/usr/include/c++/11/bits/range_access.h:51:50: error: 'struct std::pair<int, int>' has no member named 'begin'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |                                           ~~~~~~~^~~~~
/usr/include/c++/11/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++/11/bits/range_access.h:61:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::pair<int, int>]':
factories.cpp:67:51:   required from here
/usr/include/c++/11/bits/range_access.h:61:56: error: 'const struct std::pair<int, int>' has no member named 'begin'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |                                                 ~~~~~~~^~~~~
/usr/include/c++/11/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]) noexcept
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:90:5: note:   template argument deduction/substitution failed:
factories.cpp:67:51: note:   mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from factories.cpp:2:
/usr/include/c++/11/valarray:1217:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
 1217 |     begin(valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1217:5: note:   template argument deduction/substitution failed:
factories.cpp:67:51: note:   'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from factories.cpp:2:
/usr/include/c++/11/valarray:1228:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1228:5: note:   template argument deduction/substitution failed:
factories.cpp:67:51: note:   'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
factories.cpp:67:51: error: no matching function for call to 'end(std::pair<int, int>&)'
In file included from /usr/include/c++/11/bits/algorithmfwd.h:39,
                 from /usr/include/c++/11/bits/stl_algo.h:60,
                 from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from factories.cpp:2:
/usr/include/c++/11/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++/11/initializer_list:101:5: note:   template argument deduction/substitution failed:
factories.cpp:67:51: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from factories.cpp:2:
/usr/include/c++/11/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++/11/bits/range_access.h:71:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = std::pair<int, int>]':
factories.cpp:67:51:   required from here
/usr/include/c++/11/bits/range_access.h:71:48: error: 'struct std::pair<int, int>' has no member named 'end'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |                                         ~~~~~~~^~~
/usr/include/c++/11/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++/11/bits/range_access.h:81:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = std::pair<int, int>]':
factories.cpp:67:51:   required from here
/usr/include/c++/11/bits/range_access.h:81:54: error: 'const struct std::pair<int, int>' has no member named 'end'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |                                               ~~~~~~~^~~
/usr/include/c++/11/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]) noexcept
      |     ^~~
/usr/include/c++/11/bits/range_access.h:100:5: note:   template argument deduction/substitution failed:
factories.cpp:67:51: note:   mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from factories.cpp:2:
/usr/include/c++/11/valarray:1239:5: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1239 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/11/valarray:1239:5: note:   template argument deduction/substitution failed:
factories.cpp:67:51: note:   'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from factories.cpp:2:
/usr/include/c++/11/valarray:1255:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1255 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/11/valarray:1255:5: note:   template argument deduction/substitution failed:
factories.cpp:67:51: note:   'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
   67 |         for(auto &[ancestor, dist]: ancestors[X[i]]) {
      |                                                   ^
factories.cpp:71:7: error: expected ';' before 'ans'
   71 |     ll ans = 0;
      |       ^~~~
      |       ;
factories.cpp:73:11: error: expected ';' before 'cnt'
   73 |         ll cnt = MXVAL;
      |           ^~~~
      |           ;
factories.cpp:74:51: error: no matching function for call to 'begin(std::pair<int, int>&)'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
In file included from /usr/include/c++/11/bits/algorithmfwd.h:39,
                 from /usr/include/c++/11/bits/stl_algo.h:60,
                 from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from factories.cpp:2:
/usr/include/c++/11/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++/11/initializer_list:90:5: note:   template argument deduction/substitution failed:
factories.cpp:74:51: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from factories.cpp:2:
/usr/include/c++/11/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++/11/bits/range_access.h:51:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::pair<int, int>]':
factories.cpp:74:51:   required from here
/usr/include/c++/11/bits/range_access.h:51:50: error: 'struct std::pair<int, int>' has no member named 'begin'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |                                           ~~~~~~~^~~~~
/usr/include/c++/11/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++/11/bits/range_access.h:61:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::pair<int, int>]':
factories.cpp:74:51:   required from here
/usr/include/c++/11/bits/range_access.h:61:56: error: 'const struct std::pair<int, int>' has no member named 'begin'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |                                                 ~~~~~~~^~~~~
/usr/include/c++/11/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]) noexcept
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:90:5: note:   template argument deduction/substitution failed:
factories.cpp:74:51: note:   mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from factories.cpp:2:
/usr/include/c++/11/valarray:1217:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
 1217 |     begin(valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1217:5: note:   template argument deduction/substitution failed:
factories.cpp:74:51: note:   'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from factories.cpp:2:
/usr/include/c++/11/valarray:1228:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1228:5: note:   template argument deduction/substitution failed:
factories.cpp:74:51: note:   'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
factories.cpp:74:51: error: no matching function for call to 'end(std::pair<int, int>&)'
In file included from /usr/include/c++/11/bits/algorithmfwd.h:39,
                 from /usr/include/c++/11/bits/stl_algo.h:60,
                 from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from factories.cpp:2:
/usr/include/c++/11/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++/11/initializer_list:101:5: note:   template argument deduction/substitution failed:
factories.cpp:74:51: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from factories.cpp:2:
/usr/include/c++/11/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++/11/bits/range_access.h:71:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = std::pair<int, int>]':
factories.cpp:74:51:   required from here
/usr/include/c++/11/bits/range_access.h:71:48: error: 'struct std::pair<int, int>' has no member named 'end'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |                                         ~~~~~~~^~~
/usr/include/c++/11/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++/11/bits/range_access.h:81:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = std::pair<int, int>]':
factories.cpp:74:51:   required from here
/usr/include/c++/11/bits/range_access.h:81:54: error: 'const struct std::pair<int, int>' has no member named 'end'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |                                               ~~~~~~~^~~
/usr/include/c++/11/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]) noexcept
      |     ^~~
/usr/include/c++/11/bits/range_access.h:100:5: note:   template argument deduction/substitution failed:
factories.cpp:74:51: note:   mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from factories.cpp:2:
/usr/include/c++/11/valarray:1239:5: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1239 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/11/valarray:1239:5: note:   template argument deduction/substitution failed:
factories.cpp:74:51: note:   'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from factories.cpp:2:
/usr/include/c++/11/valarray:1255:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1255 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/11/valarray:1255:5: note:   template argument deduction/substitution failed:
factories.cpp:74:51: note:   'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
   74 |         for(auto &[ancestor, dist]: ancestors[Y[i]]) {
      |                                                   ^
factories.cpp:76:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   76 |             cnt = min(cnt, dist + min_dist[ancestor]);
      |             ^~~
      |             int
factories.cpp:78:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   78 |         ans += cnt;
      |         ^~~
      |         abs
factories.cpp:78:16: error: 'cnt' was not declared in this scope; did you mean 'int'?
   78 |         ans += cnt;
      |                ^~~
      |                int
factories.cpp:80:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   80 |     return ans;
      |            ^~~
      |            abs