Submission #1239861

#TimeUsernameProblemLanguageResultExecution timeMemory
1239861lunarechoConnecting Supertrees (IOI20_supertrees)C++20
Compilation error
0 ms0 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; #define ll long long; struct DSU { vector<int> parent; void init(int n) { parent.resize(n); for(int i=0;i<n;++i) parent[i] = i; } int find(int x) { if(parent[x] != x) parent[x] = find(parent[x]); return parent[x]; } void unite(int a,int b) { int u = find(a), v = find(b); if(u != v) { parent[u] = v; } } }; int construct(vector<vector<int>> p) { int n = p.size(); if(n == 1) { build({{0}}); return 1; } DSU d; d.init(n); for(int i=0;i<n;++i) { for(int j=i+1;j<n;++j) { if(p[i][j] == 1) { d.unite(i,j); } } } for(int i=0;i<n;++i) { for(int j=i+1;j<n;++j) { if(p[i][j] == 0 && d.find(i) == d.find(j)) return 0; else if(p[i][j] == 1 && d.find(i) != d.find(j)) return 0; } } vector<vector<int>> ans(n,vector<int>(n)); map<int,int> helping; for(int i=0;i<n;++i) { helping[find(i)].push_back(i); } for(auto &it : mp) { vector<int> v = it.second; for(int i=1;i<v.size();++i) { int u = v[i-1], v[i]; ans[u][v] = 1; ans[v][u] = 1; } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:72:21: error: no matching function for call to 'find(int&)'
   72 |         helping[find(i)].push_back(i);
      |                 ~~~~^~~
In file included from /usr/include/c++/11/vector:62,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3876:5: note: candidate: 'template<class _IIter, class _Tp> constexpr _IIter std::find(_IIter, _IIter, const _Tp&)'
 3876 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/11/bits/stl_algo.h:3876:5: note:   template argument deduction/substitution failed:
supertrees.cpp:72:21: note:   candidate expects 3 arguments, 1 provided
   72 |         helping[find(i)].push_back(i);
      |                 ~~~~^~~
In file included from /usr/include/c++/11/bits/locale_facets.h:48,
                 from /usr/include/c++/11/bits/basic_ios.h:37,
                 from /usr/include/c++/11/ios:44,
                 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 supertrees.cpp:2:
/usr/include/c++/11/bits/streambuf_iterator.h:421:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >, const _CharT2&)'
  421 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/11/bits/streambuf_iterator.h:421:5: note:   template argument deduction/substitution failed:
supertrees.cpp:72:21: note:   mismatched types 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >' and 'int'
   72 |         helping[find(i)].push_back(i);
      |                 ~~~~^~~
In file included from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from supertrees.cpp:2:
/usr/include/c++/11/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++/11/pstl/glue_algorithm_defs.h:60:1: note:   template argument deduction/substitution failed:
supertrees.cpp:72:21: note:   candidate expects 4 arguments, 1 provided
   72 |         helping[find(i)].push_back(i);
      |                 ~~~~^~~
supertrees.cpp:75:20: error: 'mp' was not declared in this scope; did you mean 'p'?
   75 |     for(auto &it : mp)
      |                    ^~
      |                    p
supertrees.cpp:81:24: error: invalid conversion from 'int*' to 'std::vector<int>::size_type' {aka 'long unsigned int'} [-fpermissive]
   81 |                 ans[u][v] = 1;
      |                        ^
      |                        |
      |                        int*
In file included from /usr/include/c++/11/vector:67,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1043:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:82:21: error: invalid conversion from 'int*' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-fpermissive]
   82 |                 ans[v][u] = 1;
      |                     ^
      |                     |
      |                     int*
In file included from /usr/include/c++/11/vector:67,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1043:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~