# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
171042 | 2019-12-27T07:46:23 Z | dennisstar | 꿈 (IOI13_dreaming) | C++11 | 컴파일 오류 |
0 ms | 0 KB |
#include "dreaming.h" #include <bits/stdc++.h> #define fi first #define se second #define ryan bear #define all(V) ((V).begin()), ((V).end()) using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef long double ld; typedef vector<int> vim; typedef vector<ll> vlm; int N, M, L; int *A, *B, *T; vim V[100010], C[100010]; vector<pii> D1[100010]; vim D2[100010]; int chk[100010]; vim ar; int mx; int dfs1(int now, int par, int dep) { chk[now]=1; for (int i=0; i<V[now].size(); i++) { if (chk[V[now][i]]) continue; D1[now].push_back({dfs1(V[now][i], now, dep+C[now][i])-dep, V[now][i]}); } int ret=dep; for (int i=1; i<D1[now].size(); i++) ret=max(ret, D1[now][i].fi+dep); return ret; } int dfs2(int now, int dep) { if (!D1[now].size()) return 0; mx=max(mx, dep+D1[now][0]); if (D1[now].size()>1) mx=max(mx, D1[now][0]+D1[now][1]); chk[now]=1; int ret=max(dep, D1[now][0].fi); for (int i=0; i<V[now].size(); i++) { if (chk[V[now][i]]) continue; ret=min(ret, dfs2(V[now][i], max(dep, (D1[now][0].se==V[now][i]?(D1[now].size()>1?D1[now][1].fi:0):D1[now][0].fi))+C[now][i])); } return ret; } int travelTime(int N_, int M_, int L_, int A_[], int B_[], int T_[]) { N=N_; M=M_; L=L_; A=A_; B=B_; T=T_; for (int i=0; i<M; i++) { V[A[i]+1].push_back(B[i]+1); V[B[i]+1].push_back(A[i]+1); C[A[i]+1].push_back(T[i]); C[B[i]+1].push_back(T[i]); } for (int i=1; i<=N; i++) if (!chk[i]) {dfs1(i, 0, 0);} for (int i=1; i<=N; i++) sort(all(D1[i]), [](pii x1, pii x2){return x1.fi>x2.fi;}); for (int i=1; i<=N; i++) chk[i]=0; for (int i=1; i<=N; i++) if (!chk[i]) {ar.push_back(dfs2(i, 0));} sort(all(ar), [](int x1, int x2){return x1>x2;}); if (ar.size()==1) return mx; else return max(mx, ar[0]+ar[1]+L); }
Compilation message
dreaming.cpp: In function 'int dfs1(int, int, int)': dreaming.cpp:26:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i=0; i<V[now].size(); i++) { ~^~~~~~~~~~~~~~ dreaming.cpp:31:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i=1; i<D1[now].size(); i++) ret=max(ret, D1[now][i].fi+dep); ~^~~~~~~~~~~~~~~ dreaming.cpp: In function 'int dfs2(int, int)': dreaming.cpp:37:16: error: no match for 'operator+' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka std::pair<int, int>}') mx=max(mx, dep+D1[now][0]); In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:397:5: note: candidate: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&) operator+(typename reverse_iterator<_Iterator>::difference_type __n, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:397:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka std::pair<int, int>}' is not derived from 'const std::reverse_iterator<_Iterator>' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:1198:5: note: candidate: template<class _Iterator> std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&) operator+(typename move_iterator<_Iterator>::difference_type __n, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1198:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka std::pair<int, int>}' is not derived from 'const std::move_iterator<_IteratorL>' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5876:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5876:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:53:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.tcc:1157:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator+(const _CharT* __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.tcc:1157:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'const _CharT*' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:53:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.tcc:1173:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) ^~~~~~~~ /usr/include/c++/7/bits/basic_string.tcc:1173:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka std::pair<int, int>}' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5913:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5913:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5929:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5929:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5941:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5941:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5947:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5947:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5953:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5953:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5965:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) operator+(const _CharT* __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5965:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'const _CharT*' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5971:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) operator+(_CharT __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5971:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka std::pair<int, int>}' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5977:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5977:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/basic_string.h:5983:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, _CharT) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5983:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/ccomplex:39:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/complex:326:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator+(const std::complex<_Tp>&, const std::complex<_Tp>&) operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) ^~~~~~~~ /usr/include/c++/7/complex:326:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'const std::complex<_Tp>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/ccomplex:39:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/complex:335:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator+(const std::complex<_Tp>&, const _Tp&) operator+(const complex<_Tp>& __x, const _Tp& __y) ^~~~~~~~ /usr/include/c++/7/complex:335:5: note: template argument deduction/substitution failed: dreaming.cpp:37:26: note: mismatched types 'const std::complex<_Tp>' and 'int' mx=max(mx, dep+D1[now][0]); ^ In file included from /usr/include/c++/7/ccomplex:39:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/complex:344:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator+(const _Tp&, const std::complex<_Tp>&) operator+(const _Tp& __x, const complex<_Tp>& __y) ^~~~~~~~ /usr/include/c++/7/complex:344:5: note: template argument deduction/substitution failed: /var/lo