Submission #1051881

#TimeUsernameProblemLanguageResultExecution timeMemory
1051881MarwenElarbiFountain Parks (IOI21_parks)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "parks.h" #define pb push_back #define fi first #define se second const int nax=2e5+5; set<pair<int,int>> mp; map<pair<int,int>,int> cor; set<pair<int,int>> vis; int parent[nax]; bool check(pair<int,int> a){ if(!mp.count({a.fi-2,a.se})&&!mp.count({a.fi+2,a.se})&&!mp.count({a.fi,a.se-2})&&!mp.count({a.fi,a.se+2})) return false; return true; } int find(int x){ if(x==parent[x]) return x; return parent[x]=find(parent[x]); } bool sameset(int x,int y){ return find(x)==find(y); } void joinset(int x,int y) { x=find(x); y=find(y); pair[x]=y; } int construct_roads(std::vector<int> x, std::vector<int> y) { if (x.size() == 1) { build({}, {}, {}, {}); return 1; } std::vector<int> u, v, a, b; int n=y.size(); for (int i = 0; i < n; ++i) parent[i]=i; for (int i = 0; i < n; ++i) { mp.insert({x[i],y[i]}); cor[{x[i],y[i]}]=i; } bool test=true; for(auto i:mp){ if(!check(i)){ test=false; break; } if(mp.count({i.fi+2,i.se})){ if(sameset(cor[i],cor[{i.fi+2,i.se}])) continue; joinset(cor[i],cor[{i.fi+2,i.se}]); pair<int,int> cur={i.fi+1,i.se+1}; if(vis.count(cur)) cur.se-=2; vis.insert(cur); a.pb(cur.fi); b.pb(cur.se); u.pb(cor[i]); v.pb(cor[{i.fi+2,i.se}]); } if(mp.count({i.fi,i.se+2})){ if(sameset(cor[i],cor[{i.fi+2,i.se}])) continue; joinset(cor[i],cor[{i.fi+2,i.se}]); pair<int,int> cur={i.fi+1,i.se+1}; if(vis.count(cur)) cur.fi-=2; vis.insert(cur); a.pb(cur.fi); b.pb(cur.se); u.pb(cor[i]); v.pb(cor[{i.fi,i.se+2}]); } } if(!test) return 0; if((int)u.size()!=n-1) return 0; build(u, v, a, b); return 1; }

Compilation message (stderr)

parks.cpp: In function 'void joinset(int, int)':
parks.cpp:26:10: error: declaration of 'auto x' shadows a parameter
   26 |     pair[x]=y;
      |          ^
parks.cpp:23:18: note: 'int x' previously declared here
   23 | void joinset(int x,int y) {
      |              ~~~~^
parks.cpp:26:13: error: class template argument deduction failed:
   26 |     pair[x]=y;
      |             ^
parks.cpp:26:13: error: no matching function for call to 'pair(int&)'
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:460:40: note: candidate: 'template<class _T1, class _T2> std::pair(_T1, _T2)-> std::pair<_T1, _T2>'
  460 |   template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
      |                                        ^~~~
/usr/include/c++/10/bits/stl_pair.h:460:40: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   candidate expects 2 arguments, 1 provided
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: candidate: 'template<class _T1, class _T2> pair(std::pair<_T1, _T2>)-> std::pair<_T1, _T2>'
  211 |     struct pair
      |            ^~~~
/usr/include/c++/10/bits/stl_pair.h:211:12: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:232:26: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> >::value, bool>::type <anonymous> > pair()-> std::pair<_T1, _T2>'
  232 |       _GLIBCXX_CONSTEXPR pair()
      |                          ^~~~
/usr/include/c++/10/bits/stl_pair.h:232:26: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   candidate expects 0 arguments, 1 provided
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:266:17: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<true, _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(const _T1&, const _T2&)-> std::pair<_T1, _T2>'
  266 |       constexpr pair(const _T1& __a, const _T2& __b)
      |                 ^~~~
/usr/include/c++/10/bits/stl_pair.h:266:17: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   candidate expects 2 arguments, 1 provided
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:300:19: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(const std::pair<_ForwardIterator1, _ForwardIterator2>&)-> std::pair<_T1, _T2>'
  300 |         constexpr pair(const pair<_U1, _U2>& __p)
      |                   ^~~~
/usr/include/c++/10/bits/stl_pair.h:300:19: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   mismatched types 'const std::pair<_ForwardIterator1, _ForwardIterator2>' and 'int'
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:314:17: note: candidate: 'template<class _T1, class _T2> pair(const std::pair<_T1, _T2>&)-> std::pair<_T1, _T2>'
  314 |       constexpr pair(const pair&) = default; ///< Copy constructor
      |                 ^~~~
/usr/include/c++/10/bits/stl_pair.h:314:17: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:315:17: note: candidate: 'template<class _T1, class _T2> pair(std::pair<_T1, _T2>&&)-> std::pair<_T1, _T2>'
  315 |       constexpr pair(pair&&) = default;  ///< Move constructor
      |                 ^~~~
/usr/include/c++/10/bits/stl_pair.h:315:17: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:322:18: note: candidate: 'template<class _T1, class _T2, class _U1, typename std::enable_if<std::_PCC<true, _T1, _T2>::_MoveCopyPair<true, _U1, _T2>(), bool>::type <anonymous> > pair(_U1&&, const _T2&)-> std::pair<_T1, _T2>'
  322 |        constexpr pair(_U1&& __x, const _T2& __y)
      |                  ^~~~
/usr/include/c++/10/bits/stl_pair.h:322:18: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   candidate expects 2 arguments, 1 provided
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:336:18: note: candidate: 'template<class _T1, class _T2, class _U2, typename std::enable_if<std::_PCC<true, _T1, _T2>::_CopyMovePair<true, _T1, _U2>(), bool>::type <anonymous> > pair(const _T1&, _U2&&)-> std::pair<_T1, _T2>'
  336 |        constexpr pair(const _T1& __x, _U2&& __y)
      |                  ^~~~
/usr/include/c++/10/bits/stl_pair.h:336:18: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   candidate expects 2 arguments, 1 provided
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:352:12: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(_U1&&, _U2&&)-> std::pair<_T1, _T2>'
  352 |  constexpr pair(_U1&& __x, _U2&& __y)
      |            ^~~~
/usr/include/c++/10/bits/stl_pair.h:352:12: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   candidate expects 2 arguments, 1 provided
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:371:12: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(std::pair<_ForwardIterator1, _ForwardIterator2>&&)-> std::pair<_T1, _T2>'
  371 |  constexpr pair(pair<_U1, _U2>&& __p)
      |            ^~~~
/usr/include/c++/10/bits/stl_pair.h:371:12: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   mismatched types 'std::pair<_ForwardIterator1, _ForwardIterator2>' and 'int'
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/functional:54,
                 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 parks.cpp:1:
/usr/include/c++/10/tuple:1673:7: note: candidate: 'template<class _T1, class _T2, class ... _Args1, class ... _Args2> pair(std::piecewise_construct_t, std::tuple<_Tail ...>, std::tuple<_Args2 ...>)-> std::pair<_T1, _T2>'
 1673 |       pair<_T1, _T2>::
      |       ^~~~~~~~~~~~~~
/usr/include/c++/10/tuple:1673:7: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   candidate expects 3 arguments, 1 provided
   26 |     pair[x]=y;
      |             ^
In file included from /usr/include/c++/10/functional:54,
                 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 parks.cpp:1:
/usr/include/c++/10/tuple:1685:7: note: candidate: 'template<class _T1, class _T2, class ... _Args1, long unsigned int ..._Indexes1, class ... _Args2, long unsigned int ..._Indexes2> pair(std::tuple<_Tail ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes2 ...>, std::_Index_tuple<_Indexes2 ...>)-> std::pair<_T1, _T2>'
 1685 |       pair<_T1, _T2>::
      |       ^~~~~~~~~~~~~~
/usr/include/c++/10/tuple:1685:7: note:   template argument deduction/substitution failed:
parks.cpp:26:13: note:   mismatched types 'std::tuple<_Tail ...>' and 'int'
   26 |     pair[x]=y;
      |             ^
parks.cpp:26:13: note: explicit deduction guides not considered for copy-initialization