# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335199 | 2020-12-11T12:26:56 Z | blue | 꿈 (IOI13_dreaming) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
#include "dreaming.h" #include <iostream> #include <vector> #include <set> #include <algorithm> #include <queue> using namespace std; vector<int> edge[100001]; vector<int> weight[100001]; vector<int> maxdist(100001, 0); vector<int> children(100001, 0); vector<int> visit(100001, 0); vector<int> roots; struct distcomp { int i; }; bool operator () (distcomp a, distcomp b) { if(maxdist[a.i] == maxdist[b.i]) return a.i < b.i; return maxdist[a.i] < maxdist[b.i]; } int travelTime(int N, int M, int L, int A[], int B[], int T[]) //number of nodes, number of edges, common length, edge A[i]-A[i] with length T[i] { for(int i = 0; i < M; i++) { edge[A[i]].push_back(B[i]); weight[A[i]].push_back(T[i]); edge[B[i]].push_back(A[i]); weight[B[i]].push_back(T[i]); } //set<int, distcomp> tbv; set<distcomp> tbv; for(int i = 0; i < N; i++) { if(edge[i].size() == 0) roots.push_back(0); if(edge[i].size() == 1) tbv.insert(distcomp{i}); } int u, v, w; while(!tbv.empty()) { u = tbv.begin()->i; tbv.erase(tbv.begin()); visit[u] = 1; for(int i = 0; i < edge[u].size(); i++) { v = edge[u][i]; w = weight[u][i]; if(!visit[v]) { children[v]++; maxdist[v] = max(maxdist[v], maxdist[u] + w); if(children[v] == edge[v].size() - 1) tbv.insert(distcomp{v}); } else { maxdist[u] = max(maxdist[u], maxdist[v] + w); } } if(edge[u].size() == children[u]) roots.push_back(maxdist[u]); } if(M == N-1) return roots[0]; else { sort(roots.begin(), roots.end()); return roots[roots.size() - 2] + L + roots[roots.size() - 1]; } }
Compilation message
dreaming.cpp:21:6: error: 'bool operator()(distcomp, distcomp)' must be a nonstatic member function 21 | bool operator () (distcomp a, distcomp b) | ^~~~~~~~ dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)': dreaming.cpp:53:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 53 | for(int i = 0; i < edge[u].size(); i++) | ~~^~~~~~~~~~~~~~~~ dreaming.cpp:62:32: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 62 | if(children[v] == edge[v].size() - 1) tbv.insert(distcomp{v}); dreaming.cpp:69:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare] 69 | if(edge[u].size() == children[u]) roots.push_back(maxdist[u]); In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = distcomp]': /usr/include/c++/9/bits/stl_tree.h:2095:11: required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = distcomp; _Val = distcomp; _KeyOfValue = std::_Identity<distcomp>; _Compare = std::less<distcomp>; _Alloc = std::allocator<distcomp>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = distcomp]' /usr/include/c++/9/bits/stl_tree.h:2148:4: required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = distcomp; _Key = distcomp; _Val = distcomp; _KeyOfValue = std::_Identity<distcomp>; _Compare = std::less<distcomp>; _Alloc = std::allocator<distcomp>]' /usr/include/c++/9/bits/stl_set.h:520:48: required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = distcomp; _Compare = std::less<distcomp>; _Alloc = std::allocator<distcomp>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<distcomp>; std::set<_Key, _Compare, _Alloc>::value_type = distcomp]' dreaming.cpp:43:55: required from here /usr/include/c++/9/bits/stl_function.h:386:20: error: no match for 'operator<' (operand types are 'const distcomp' and 'const distcomp') 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:64, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_pair.h:454:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)' 454 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/9/bits/stl_pair.h:454:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'const distcomp' is not derived from 'const std::pair<_T1, _T2>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:67, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_iterator.h:331:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)' 331 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/9/bits/stl_iterator.h:331:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'const distcomp' is not derived from 'const std::reverse_iterator<_Iterator>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:67, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_iterator.h:369:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)' 369 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/9/bits/stl_iterator.h:369:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'const distcomp' is not derived from 'const std::reverse_iterator<_Iterator>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:67, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_iterator.h:1163:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)' 1163 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/9/bits/stl_iterator.h:1163:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'const distcomp' is not derived from 'const std::move_iterator<_IteratorL>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:67, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_iterator.h:1169:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)' 1169 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/9/bits/stl_iterator.h:1169:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'const distcomp' is not derived from 'const std::move_iterator<_IteratorL>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/basic_string.h:48, from /usr/include/c++/9/string:55, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/string_view:509:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(std::basic_string_view<_CharT, _Traits>, std::basic_string_view<_CharT, _Traits>)' 509 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/9/string_view:509:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'distcomp' is not derived from 'std::basic_string_view<_CharT, _Traits>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/basic_string.h:48, from /usr/include/c++/9/string:55, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/string_view:515:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(std::basic_string_view<_CharT, _Traits>, std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >)' 515 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/9/string_view:515:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'distcomp' is not derived from 'std::basic_string_view<_CharT, _Traits>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/basic_string.h:48, from /usr/include/c++/9/string:55, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/string_view:521:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >, std::basic_string_view<_CharT, _Traits>)' 521 | operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/9/string_view:521:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'distcomp' is not derived from 'std::basic_string_view<_CharT, _Traits>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/string:55, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/basic_string.h:6226:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 6226 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/basic_string.h:6226:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'const distcomp' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/string:55, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/basic_string.h:6239:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 6239 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/basic_string.h:6239:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: 'const distcomp' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/string:55, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/basic_string.h:6251:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 6251 | operator<(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/basic_string.h:6251:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/string:48, from /usr/include/c++/9/bits/locale_classes.h:40, from /usr/include/c++/9/bits/ios_base.h:41, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/bits/stl_function.h:386:20: note: mismatched types 'const _CharT*' and 'distcomp' 386 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/9/bits/ios_base.h:46, from /usr/include/c++/9/ios:42, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from dreaming.cpp:2: /usr/include/c++/9/system_error:208:3: note: candidate: 'bool std::operator<(const std::error_code&, const std::error_code&)' 208 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept | ^~~~~~~~ /usr/include/c++/9/system_error:208:31: note: no known conversion for argument 1 from 'const distcomp' to 'const std::error_code&' 208 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept | ~~~~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/9/system_error:282:3: note: candidate: 'bool std::operator<(const std::error_condition&, const std::error_condition&)' 282 | operator<(const error_condition& __lhs, |