Submission #488086

#TimeUsernameProblemLanguageResultExecution timeMemory
488086SlavicGConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include "supertrees.h" #include "bits/stdc++.h" using namespace std; #define ll long long #define forn(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define sz(a) (int)a.size() struct DSU{ int n; vector<int> par, s; DSU(int N){ n = N; s.assign(n, 1), par.resize(n); iota(all(par), 0); } int get(int a){ return par[a] = (a == par[a] ? a : get(par[a])); } void uni(int a, int b){ a = get(a), b = get(b); if(s[a] > s[b])swap(a, b); par[a] = b, s[b] += s[a]; } int get_size(int a){ return s[get(a)]; } bool same_set(int a, int b){ return get(a) == get(b); } }; const int N = 1005; vector<int> adj[N], adj2[N]; vector<int> component; bool vis[N]; void dfs(int u){ component.pb(u); vis[u] = true; for(int v: adj[u])if(!vis[v])dfs(v); } int construct(vector<vector<int>> p){ int n = sz(p); vector<vector<int>> ans(n, vector<int>(n, 0)); forn(i,n)adj[i].clear(), adj2[i].clear(); DSU d(n); DSU fuck(n); for(int i = 0;i < n; ++i){ for(int j = 0;j < n; ++j){ if(i == j)continue; if(p[i][j] != p[j][i])return 0; } } for(int i = 0;i < n; ++i){ vis[i] = false; for(int j = 0;j < n; ++j){ if(p[i][j] == 2 && i != j){ adj[i].pb(j); } if(p[i][j] == 1 && i != j){ if(!d.same_set(i, j)){ d.uni(i, j); ans[i][j] = ans[j][i] = 1; } } } } for(int i = 0;i < n; ++i){ if(!vis[d.get(i)]){ component.clear(); dfs(i); vector<int> temp; for(auto x: component)vis[get(x)] = true; for(int i = 0;i < sz(component);++i){ component[i] = d.get(component[i]); } sort(all(component)); component.erase(inuque(all(component)), component.end()); if(sz(component) == 2)return 0; for(int i = 0;i < sz(component); ++i){ if(sz(component) > 1)ans[component[i]][component[(i + 1) % sz(component)]] = ans[component[(i + 1) % sz(component)]][component[i]] = 1; fuck.uni(component[i], component[(i + 1) % sz(component)]); } } } for(int i = 0;i < n; ++i){ for(int j = 0;j < n; ++j){ if(i == j)continue; if(ans[i][j] && !p[i][j])return 0; if(fuck.same_set(i, j) && !p[i][j])return 0; if(d.same_set(i, j) && !p[i][j])return 0; } } for(int i = 0;i < n; ++i){ adj[i].clear(); adj2[i].clear(); vis[i] = false; } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:85:44: error: no matching function for call to 'get(int&)'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:223:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)'
  223 |     get(std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:223:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:228:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)'
  228 |     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:228:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:233:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)'
  233 |     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:233:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:238:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)'
  238 |     get(const std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:238:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)'
  247 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:247:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)'
  252 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:252:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)'
  257 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:257:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)'
  262 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:262:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)'
  267 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:267:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)'
  272 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:272:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)'
  277 |     get(pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:277:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)'
  282 |     get(const pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:282:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/tuple:39,
                 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 supertrees.cpp:2:
/usr/include/c++/10/array:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)'
  334 |     get(array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:334:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/tuple:39,
                 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 supertrees.cpp:2:
/usr/include/c++/10/array:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)'
  343 |     get(array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:343:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/tuple:39,
                 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 supertrees.cpp:2:
/usr/include/c++/10/array:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)'
  351 |     get(const array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:351:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
In file included from /usr/include/c++/10/tuple:39,
                 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 supertrees.cpp:2:
/usr/include/c++/10/array:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)'
  360 |     get(const array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:360:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
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 supertrees.cpp:2:
/usr/include/c++/10/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(std::tuple<_UTypes ...>&)'
 1294 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1294:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
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 supertrees.cpp:2:
/usr/include/c++/10/tuple:1300:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(const std::tuple<_UTypes ...>&)'
 1300 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1300:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::tuple<_UTypes ...>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
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 supertrees.cpp:2:
/usr/include/c++/10/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(std::tuple<_UTypes ...>&&)'
 1306 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1306:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
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 supertrees.cpp:2:
/usr/include/c++/10/tuple:1315:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(const std::tuple<_UTypes ...>&&)'
 1315 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1315:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::tuple<_UTypes ...>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
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 supertrees.cpp:2:
/usr/include/c++/10/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_UTypes ...>&)'
 1338 |     get(tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1338:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
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 supertrees.cpp:2:
/usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_UTypes ...>&&)'
 1344 |     get(tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1344:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
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 supertrees.cpp:2:
/usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_UTypes ...>&)'
 1350 |     get(const tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1350:5: note:   template argument deduction/substitution failed:
supertrees.cpp:85:44: note:   mismatched types 'const std::tuple<_UTypes ...>' and 'int'
   85 |             for(auto x: component)vis[get(x)] = true;
      |                                            ^
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 supertrees.cpp:2:
/usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_UTypes ...>&&)'
 1357 |     get(const tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1357:5: note:   template argument deduction/substitution failed:
/var