Submission #700206

#TimeUsernameProblemLanguageResultExecution timeMemory
700206mnbvcxz123Race (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "race.h"
using namespace std;
using ll=long long;
using ar=array<ll,2>;
ll n,k,res=1e7;
vector<ar>g[200000];
int sz[200000];
bool used[200000];
map<ll,int>mp;
void siz(int v, int e){
        sz[v]=1;
        for(const auto&[i,w]:g[v])
                if(i!=e and !used[i]) siz(i,v),sz[v]+=sz[i];
}
int get(int v, int e, int des){
        for(const auto&[i,w]:g[v])
                if(i!=e and !used[i] and sz[i]>des) return get(i,v,des);
        return v;
}
void help(int v, int e, ll km, int d, bool fill){
        if(km>k) return;
        if(fill){
                if(!mp.count(km)) mp[km]=d;
                else mp[km]=min(mp[km],d);
        }
        else{
                if(km==k) res=min(res,d);
                else if(mp.count(k-km)) res=min(res,d+mp[k-km]);
        }
        for(const auto&[i,w]:g[v])
                if(i!=e and !used[i]) help(i,v,km+w,d+1,fill);
}
void decomp(int v=0){
        siz(v,-1);
        int c=get(v,-1,sz[v]>>1);
        used[c]=1;
        mp[c]=0;
        for(const auto&[i,w]:g[c])
                if(!used[i]){
                        help(i,c,w,1,0);
                        help(i,c,w,1,1);
                }
        mp.clear();
        for(const auto&[i,w]:g[c])
                if(!used[i]) decomp(i);
}
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]].push_back({H[i][1],L[i]});
                g[H[i][1]].push_back({H[i][0],L[i]});
        }
        decomp();
        if(res==1e7) res=-1;
        return res;
}

Compilation message (stderr)

race.cpp: In function 'void help(int, int, ll, int, bool)':
race.cpp:28:40: error: no matching function for call to 'min(ll&, int&)'
   28 |                 if(km==k) res=min(res,d);
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 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:28:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |                 if(km==k) res=min(res,d);
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 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:28:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |                 if(km==k) res=min(res,d);
      |                                        ^
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:28:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |                 if(km==k) res=min(res,d);
      |                                        ^
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:28:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |                 if(km==k) res=min(res,d);
      |                                        ^
race.cpp:29:63: error: no matching function for call to 'min(ll&, int)'
   29 |                 else if(mp.count(k-km)) res=min(res,d+mp[k-km]);
      |                                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 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:29:63: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |                 else if(mp.count(k-km)) res=min(res,d+mp[k-km]);
      |                                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 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:29:63: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |                 else if(mp.count(k-km)) res=min(res,d+mp[k-km]);
      |                                                               ^
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:29:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |                 else if(mp.count(k-km)) res=min(res,d+mp[k-km]);
      |                                                               ^
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:29:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |                 else if(mp.count(k-km)) res=min(res,d+mp[k-km]);
      |                                                               ^