Submission #1310923

#TimeUsernameProblemLanguageResultExecution timeMemory
1310923hitsuujRace (IOI11_race)C++20
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define pb push_back #define ll long long #define inf 1e9 const int lim=2e5; vector<pii>g[lim+10]; ll dis[lim+10]; vector<int>l(lim+10); int ans=inf,n,k; // somehow semakin besar knya bakalan salah map<ll,ll> dfs(int u,int par,int dep){ map<ll,ll>cur; cur[dis[u]]=dep; for(auto [v,w]:g[u]){ if(v==par) continue; dis[v]=dis[u]+w; map<ll,ll> anak=dfs(v,u,dep+1); if(anak.size()>cur.size()){ swap(cur,anak); } for(auto [x,y]:anak){ if(!y) continue; ll tar=k-x+2*dis[u]; if(tar<0) continue; if(cur[tar]){ ans=min(ans,cur[tar]+y-2*dep); } if(cur[x]) cur[x]=min(cur[x],y); else cur[x]=y; } } return cur; } int best_path(int N, int K, int H[][2], int L[]) { n=N,k=K; for(int i=0;i<n-1;i++){ g[H[i][0]].pb({H[i][1],L[i]}); g[H[i][1]].pb({H[i][0],L[i]}); } dfs(1,-1,0); if(ans==inf) return -1; return ans; }

Compilation message (stderr)

race.cpp: In function 'std::map<long long int, long long int> dfs(int, int, int)':
race.cpp:29:24: error: no matching function for call to 'min(int&, std::map<long long int, long long int>::mapped_type)'
   29 |                 ans=min(ans,cur[tar]+y-2*dep);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from race.cpp:2:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
race.cpp:29:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::map<long long int, long long int>::mapped_type' {aka 'long long int'})
   29 |                 ans=min(ans,cur[tar]+y-2*dep);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
race.cpp:29:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::map<long long int, long long int>::mapped_type' {aka 'long long int'})
   29 |                 ans=min(ans,cur[tar]+y-2*dep);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
race.cpp:29:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |                 ans=min(ans,cur[tar]+y-2*dep);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
race.cpp:29:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |                 ans=min(ans,cur[tar]+y-2*dep);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~