제출 #866638

#제출 시각아이디문제언어결과실행 시간메모리
866638Irate경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "race.h" using namespace std; const int mxN = 2e5 + 3; vector<pair<int, int>>G[mxN]; map<long long, int>cnt[mxN]; long long depth[mxN], length[mxN]; int K; long long mn = 1e18; void dfs(int node, int par){ cnt[node][length[node]] = depth[node]; for(pair<int, int>& v : G[node]){ if(v.first != par){ depth[v.first] = depth[node] + 1; length[v.first] = length[node] + v.second; dfs(v.first, node); if(cnt[node].size() < cnt[v.first].size())swap(cnt[node], cnt[v.first]); for(auto itr = cnt[v.first].begin();itr != cnt[v.first].end();++itr){ long long num = itr->first, dep = itr->second; if(cnt[node].count(K + 2 * length[node] - num)){ mn = min(mn, dep + cnt[node][K + 2 * length[node] - num] - 2 * depth[node]); } if(cnt[node].count(num)){ cnt[node][num] = min(cnt[node][num], dep); } else{ cnt[node][num] = dep; } } } } } int best_path(int n, int k, int H[][2], int L[]){ K = k; for(int i = 0;i < n - 1;++i){ int u = H[i][0], v = H[i][1]; G[u].push_back({v, L[i]}); G[v].push_back({u, L[i]}); } dfs(0, 0); if(mn == 1e18)return -1; return mn; } // int main() // { // ios_base::sync_with_stdio(0); // cin.tie(0); // int n; // cin >> n >> K; // int H[n - 1][2], L[n - 1]; // for(int i = 0;i < n - 1;++i){ // cin >> H[i][0] >> H[i][1] >> L[i]; // } // cout << best_path(n, K, H, L); // } /* 11 12 0 1 3 0 2 4 2 3 5 3 4 4 4 5 6 0 6 3 6 7 2 6 8 5 8 9 6 8 10 7 */

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

race.cpp: In function 'void dfs(int, int)':
race.cpp:24:46: error: no matching function for call to 'min(std::map<long long int, int>::mapped_type&, long long int&)'
   24 |      cnt[node][num] = min(cnt[node][num], dep);
      |                                              ^
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 race.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
race.cpp:24:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |      cnt[node][num] = min(cnt[node][num], dep);
      |                                              ^
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 race.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
race.cpp:24:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |      cnt[node][num] = min(cnt[node][num], dep);
      |                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
race.cpp:24:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |      cnt[node][num] = min(cnt[node][num], dep);
      |                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
race.cpp:24:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |      cnt[node][num] = min(cnt[node][num], dep);
      |                                              ^