제출 #661295

#제출 시각아이디문제언어결과실행 시간메모리
661295atigunDreaming (IOI13_dreaming)C++11
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include"dreaming.h" using namespace std; typedef long long ll; const int maxn = 1e5; vector<vector<pair<int, int>>> g(maxn+5); vector<bool> vis(maxn+5, false); vector<int> dt(maxn+5), ht(maxn+5, 0), group(maxn+5); vector<multiset<int>> S(maxn+5); void dfs1(int v, int P){ group[v] = P; vis[v] = 1; int maxi1 = 0, maxi2 = 0; for(pair<int, int> pp : g[v]){ int u = pp.first, w = pp.second; if(vis[u]) continue; dfs1(u, P); ht[v] = max(ht[v], ht[u]+w); if(ht[u]+w >= maxi1){ maxi2 = maxi1, maxi1 = ht[u]+w; } else if(ht[u]+w >= maxi2){ maxi2 = ht[u]+w; } } dt[v] = maxi1+maxi2; } void dfs2(int v, int p){ vis[v] = 1; for(pair<int, int> pp : g[v]){ int u = pp.first, w = pp.second; if(u == p) continue; S[v].insert(ht[u]+w); } for(pair<int, int> pp : g[v]){ int u = pp.first, w = pp.second; if(u == p) continue; if(S[v].size() == 1){ S[u].insert(w); } else if(!S[v].empty()){ S[v].erase(S[v].find(ht[u]+w)); int best = *--S[v].end(); S[u].insert(best+w); S[v].insert(ht[u]+w); } } if(!S[v].empty()) ht[v] = *--S[v].end(); for(pair<int, int> pp : g[v]){ int u = pp.first; if(vis[u]) continue; dfs2(u, v); } } int travelTime(int N, int M, int L, int A[], int B[], int T[]){ for(int i = 0; i < M; i++){ g[A[i]].emplace_back(B[i], T[i]); g[B[i]].emplace_back(A[i], T[i]); } for(int i = 0; i < N; i++) if(!vis[i]) dfs1(i, i); fill(vis.begin(), vis.end(), false); for(int i = 0; i < N; i++) if(!vis[i]) dfs2(i, -1); long long ans = 0; for(int i = 0; i < N; i++) ans = max(ans, dt[i]); vector<pair<int, int>> order; order.reserve(N); for(int i = 0; i < N; i++) order.emplace_back(ht[i], group[i]); sort(order.begin(), order.end()); vector<int> G; G.reserve(N); vector<bool> used(N+5, false); for(int i = 0; i < N; i++){ if(used[order[i].second]) continue; G.emplace_back(order[i].first); used[order[i].second] = true; } int GN = G.size(); sort(G.begin(), G.end(), [&](int n1, int n2){ return n1 > n2; }); for(int i = GN-1; i > 0; i--) ans = max(ans, (long long) G[0] + (long long) G[i] + i*1ll*L); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:77:25: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   77 |     ans = max(ans, dt[i]);
      |                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 dreaming.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
dreaming.cpp:77:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   77 |     ans = max(ans, dt[i]);
      |                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 dreaming.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
dreaming.cpp:77:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   77 |     ans = max(ans, dt[i]);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dreaming.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
dreaming.cpp:77:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   77 |     ans = max(ans, dt[i]);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dreaming.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
dreaming.cpp:77:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   77 |     ans = max(ans, dt[i]);
      |                         ^