# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
579172 | 2022-06-18T12:40:55 Z | Trisanu_Das | Kutije (COCI21_kutije) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; int parent[1001]; int Find(int u){ if(u = parent[u]) return u; return parent[u] = find(parent[u]); } void Unite(int u, int v){ u = find(u); v = find(v); if(u == v) return; parent[v] = u; } int main(){ int n, m, q; cin >> n >> m >> q; for(int i = 1; i <= n; i++) { par[i] = i; } for(int i = 1; i <= m; i++) { for(int j = 1; j <= n; j++) { int x; cin >> x; if(Find(x) != Find(j)) { Unite(x, j); } } } for(int i = 1; i <= q; i++) { int a, b; cin >> a >> b; if(Find(a) != Find(b)) { cout << "NE\n"; } else { cout << "DA\n"; } } }
Compilation message
Main.cpp: In function 'int Find(int)': Main.cpp:7:8: warning: suggest parentheses around assignment used as truth value [-Wparentheses] 7 | if(u = parent[u]) return u; | ~~^~~~~~~~~~~ Main.cpp:8:36: error: no matching function for call to 'find(int&)' 8 | return parent[u] = find(parent[u]); | ^ 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 Main.cpp:1: /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: Main.cpp:8:36: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int' 8 | return parent[u] = find(parent[u]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /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: Main.cpp:8:36: note: candidate expects 3 arguments, 1 provided 8 | return parent[u] = find(parent[u]); | ^ In file included from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /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: Main.cpp:8:36: note: candidate expects 4 arguments, 1 provided 8 | return parent[u] = find(parent[u]); | ^ Main.cpp: In function 'void Unite(int, int)': Main.cpp:12:13: error: no matching function for call to 'find(int&)' 12 | u = find(u); v = find(v); | ^ 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 Main.cpp:1: /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: Main.cpp:12:13: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int' 12 | u = find(u); v = find(v); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /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: Main.cpp:12:13: note: candidate expects 3 arguments, 1 provided 12 | u = find(u); v = find(v); | ^ In file included from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /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: Main.cpp:12:13: note: candidate expects 4 arguments, 1 provided 12 | u = find(u); v = find(v); | ^ Main.cpp:12:26: error: no matching function for call to 'find(int&)' 12 | u = find(u); v = find(v); | ^ 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 Main.cpp:1: /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: Main.cpp:12:26: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int' 12 | u = find(u); v = find(v); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /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: Main.cpp:12:26: note: candidate expects 3 arguments, 1 provided 12 | u = find(u); v = find(v); | ^ In file included from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /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: Main.cpp:12:26: note: candidate expects 4 arguments, 1 provided 12 | u = find(u); v = find(v); | ^ Main.cpp: In function 'int main()': Main.cpp:22:3: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 22 | par[i] = i; | ^~~ | __pstl::execution::v1::par In file included from /usr/include/c++/10/pstl/glue_algorithm_defs.h:15, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/pstl/execution_defs.h:111:27: note: '__pstl::execution::v1::par' declared here 111 | constexpr parallel_policy par{}; | ^~~