Submission #651123

#TimeUsernameProblemLanguageResultExecution timeMemory
651123Clan328Connecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> using namespace std; vector<int> m_link, sz; int m_find(int x) { if (m_link[x] != x) m_link[x] = m_find(m_link[x]); return m_link[x]; } bool same(int a, int b) { return m_find(a) == m_find(b); } void unite(int a, int b) { if (a > b) swap(a, b); int x = m_find(b), y = m_find(a); if (same(x, y)) return; sz[y] += sz[x]; m_link[x] = y; } int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> answer(n, vector<int>(n)); m_link = vector<int>(n); sz = vector<int>(n, 1); iota(m_link.begin(), m_link.end(), 0); bool res = true; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) res &= p[i][j] == 1; else if (p[i][j] == 1) unite(i, j); else if (p[i][j] == 3) res = false; } } for (int i = 0; i < n; i++) { int par = m_find(i); if (par != i) { answer[par][i] = 1; answer[i][par] = 1; for (int j = 0; j < n; j++) { res &= p[i][j] == p[par][j]; } } } vector<set<int>> newNodes(n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) continue; if (p[i][j] == 2) { int p1 = m_find(i), p2 = m_find(j); unite(p1, p2); newNodes[find(p1)].insert(p1); newNodes[find(p2)].insert(p2); } } } for (int i = 0; i < n; i++) { if (newNodes[i].size() == 0) continue; res &= newNodes[i].size() > 2; for (auto it = newNodes[i].begin(); it != newNodes[i].end(); it++) { auto nxt = it; nxt++; if (nxt == newNodes[i].end()) { nxt = newNodes[i].begin(); } answer[*it][*nxt] = 1; answer[*nxt][*it] = 1; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) continue; res &= ((p[i][j] > 0) == same(i, j)); } } if (res) { build(answer); return 1; } else return 0; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:62:21: error: no matching function for call to 'find(int&)'
   62 |     newNodes[find(p1)].insert(p1);
      |                     ^
In file included from /usr/include/c++/10/bits/locale_facets.h:48,
                 from /usr/include/c++/10/bits/basic_ios.h:37,
                 from /usr/include/c++/10/ios:44,
                 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 supertrees.cpp:3:
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)'
  422 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note:   template argument deduction/substitution failed:
supertrees.cpp:62:21: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
   62 |     newNodes[find(p1)].insert(p1);
      |                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3894:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3894 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:3894:5: note:   template argument deduction/substitution failed:
supertrees.cpp:62:21: note:   candidate expects 3 arguments, 1 provided
   62 |     newNodes[find(p1)].insert(p1);
      |                     ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:3:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:60:1: note:   template argument deduction/substitution failed:
supertrees.cpp:62:21: note:   candidate expects 4 arguments, 1 provided
   62 |     newNodes[find(p1)].insert(p1);
      |                     ^
supertrees.cpp:63:21: error: no matching function for call to 'find(int&)'
   63 |     newNodes[find(p2)].insert(p2);
      |                     ^
In file included from /usr/include/c++/10/bits/locale_facets.h:48,
                 from /usr/include/c++/10/bits/basic_ios.h:37,
                 from /usr/include/c++/10/ios:44,
                 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 supertrees.cpp:3:
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)'
  422 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note:   template argument deduction/substitution failed:
supertrees.cpp:63:21: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
   63 |     newNodes[find(p2)].insert(p2);
      |                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3894:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3894 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:3894:5: note:   template argument deduction/substitution failed:
supertrees.cpp:63:21: note:   candidate expects 3 arguments, 1 provided
   63 |     newNodes[find(p2)].insert(p2);
      |                     ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from supertrees.cpp:3:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:60:1: note:   template argument deduction/substitution failed:
supertrees.cpp:63:21: note:   candidate expects 4 arguments, 1 provided
   63 |     newNodes[find(p2)].insert(p2);
      |                     ^