제출 #413671

#제출 시각아이디문제언어결과실행 시간메모리
413671Mahmudul_Kabir경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> #define sp <<" " #define el <<"\n" #define S second #define F first #define pb push_back #define all(ar) ar.begin(),ar.end() #define pii pair<ll,ll> using namespace std; using ll = long long; using ld = long double; const ll mxr = 200005; const ll big = 2000000999; ll n,k,ans = big; vector<vector<pii>> g; bitset<mxr> ded; void dfs(int v,int p,vector<int> &sz){ sz[v] = 1; for(pii r: g[v]){ if(r.F == p || ded[r.F]) continue; dfs(r.F,v,sz); sz[v] += sz[r.F]; } return; } int fcen(int v,int p,int lim,vector<int> &sz){ for(pii r: g[v]){ if(r.F == p || ded[r.F]) continue; if(sz[r.F] > lim) return fcen(r.F,v,lim,sz); } return v; } void fil(int v,int p,int cost,int dep,unordered_map<int,int> &dis,unordered_map<int,int> &cum){ if(cost > k) return; if(cum.count(k - cost)) ans = min(ans, dep + cum[k - cost]); dis[cost] = dis.count(cost) ? min(dis[cost],dep) : dep; for(pii r: g[v]){ if(r.F == p || ded[r.F]) continue; fil(r.F,v,cost + r.S,dep+1,dis,cum); } return; } void decompose(int v){ vector<int> sz(n+1); dfs(v,-1,sz); int lim = (sz[v]/2); int cen = fcen(v,-1,lim,sz); ded[cen] = 1; unordered_map<int,int> cum; for(pii r: g[cen]){ if(ded[r.F]) continue; unordered_map<int,int> dis; fil(r.F,cen,r.S,1,dis,cum); for(pii x: dis) cum[x.F] = cum.count(x.F) ? min(cum[x.F],x.S) : x.S; } if(cum.count(k)) ans = min(ans,cum[k]); for(pii r: g[cen]){ if(!ded[r.F]) decompose(r.F); } } int best_path(int N, int K, int H[][2], int L[]) { n = N; k = K; g.assign(n,{}); for(int i = 1; i < n; i++){ int a = H[i-1][0], b = H[i-1][1], c = L[i-1]; g[a].pb({b,c}); g[b].pb({a,c}); } decompose(0); return ans == big ? -1 : ans; }

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

race.cpp: In function 'void fil(int, int, int, int, std::unordered_map<int, int>&, std::unordered_map<int, int>&)':
race.cpp:45:61: error: no matching function for call to 'min(ll&, int)'
   45 |   if(cum.count(k - cost)) ans = min(ans, dep + cum[k - cost]);
      |                                                             ^
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:3:
/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:45:61: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |   if(cum.count(k - cost)) ans = min(ans, dep + cum[k - cost]);
      |                                                             ^
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:3:
/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:45:61: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |   if(cum.count(k - cost)) ans = min(ans, dep + cum[k - cost]);
      |                                                             ^
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:3:
/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:45:61: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |   if(cum.count(k - cost)) ans = min(ans, dep + cum[k - cost]);
      |                                                             ^
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:3:
/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:45:61: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |   if(cum.count(k - cost)) ans = min(ans, dep + cum[k - cost]);
      |                                                             ^
race.cpp: In function 'void decompose(int)':
race.cpp:65:65: error: no matching function for call to 'min(std::unordered_map<int, int>::mapped_type&, long long int&)'
   65 |     for(pii x: dis) cum[x.F] = cum.count(x.F) ? min(cum[x.F],x.S) : x.S;
      |                                                                 ^
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:3:
/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:65:65: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   65 |     for(pii x: dis) cum[x.F] = cum.count(x.F) ? min(cum[x.F],x.S) : x.S;
      |                                                                 ^
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:3:
/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:65:65: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   65 |     for(pii x: dis) cum[x.F] = cum.count(x.F) ? min(cum[x.F],x.S) : x.S;
      |                                                                 ^
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:3:
/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:65:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |     for(pii x: dis) cum[x.F] = cum.count(x.F) ? min(cum[x.F],x.S) : x.S;
      |                                                                 ^
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:3:
/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:65:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |     for(pii x: dis) cum[x.F] = cum.count(x.F) ? min(cum[x.F],x.S) : x.S;
      |                                                                 ^
race.cpp:67:40: error: no matching function for call to 'min(ll&, std::unordered_map<int, int>::mapped_type&)'
   67 |   if(cum.count(k)) ans = min(ans,cum[k]);
      |                                        ^
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:3:
/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:67:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::unordered_map<int, int>::mapped_type' {aka 'int'})
   67 |   if(cum.count(k)) ans = min(ans,cum[k]);
      |                                        ^
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:3:
/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:67:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::unordered_map<int, int>::mapped_type' {aka 'int'})
   67 |   if(cum.count(k)) ans = min(ans,cum[k]);
      |                                        ^
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:3:
/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:67:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   67 |   if(cum.count(k)) ans = min(ans,cum[k]);
      |                                        ^
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:3:
/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:67:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   67 |   if(cum.count(k)) ans = min(ans,cum[k]);
      |                                        ^