답안 #1088076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088076 2024-09-13T19:31:42 Z quan606303 경주 (Race) (IOI11_race) C++14
컴파일 오류
0 ms 0 KB
///0-0 : what is your motivation, quan606303?
///quan606303 : Hutao
/*idea : 
 
 
 
*/
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define INTMAX INT_MAX
#define INTMIN INT_MIN
#define LONGMAX LLONG_MAX
#define LONGMIN LLONG_MIN
#define fi first
#define se second
#define memfull(a,b) memset(a,b,sizeof(a));
#define endl '\n'
#define file(a) freopen(a".inp","r",stdin); freopen(a".out","w",stdout);
using namespace std;
const int MOD=1e9+7;
const int maxn=2e5+7;
const int maxk=1e6+7;
ll n,k,del[maxn],child[maxn];
vector<pair<int,int> > adj[maxn];
ll ans=1e15,cnt[maxk];
const ll inf=1e15;
void dfs(int u,int p)
{
    child[u]=1;
    for (auto v:adj[u])
    {
        if (v.fi!=p&&!del[v.fi])
        {
            dfs(v.fi,u);
            child[u]+=child[v.fi];
        }
    }
}
int find_centroid(int u,int p,int N)
{
    for (auto v:adj[u])
    {
        if (v.fi!=p&&!del[v.fi]&&child[v.fi]>N/2)
        {
            return find_centroid(v.fi,u,N);
        }
    }
    return u;
}
ll mxdis=0;
void cal(int u,int p,bool filling,int distance,int depth)
{
    if (distance>k)return ;
    mxdis=max(mxdis,distance);
    if (filling)cnt[distance]=min(cnt[distance],depth);
    else 
    {
        ans=min(ans,cnt[k-distance]+depth);
       // cout<<u<<" "<<distance<<" "<<depth<<" "<<cnt[k-distance]<<endl;
    }
    for (auto v:adj[u])
    {
        if (!del[v.fi]&&v.fi!=p)cal(v.fi,u,filling,distance+v.se,depth+1);
    }
}
void solve(int u)
{
    dfs(u,0);
    ll N=child[u];
    ll root=find_centroid(u,0,N);
  //  for (int i=1;i<=n;i++)cout<<child[i]<<endl;
    del[root]=true;
    
    mxdis=0;
    for (auto v:adj[root])
    {
        if (!del[v.fi])
        {
           // cout<<v.fi<<" "<<root<<" "<<v.se<<" "<<1<<endl;
            cal(v.fi,root,false,v.se,1);
            cal(v.fi,root,true,v.se,1);
        }
    }
    fill(cnt+1,cnt+1+mxdis,inf);
    for (auto v:adj[root])
    {
        if (!del[v.fi])solve(v.fi);
    }
 
}
int best_path(int N, int K, int H[][2], int L[]){
  //  file("");
    n=N;
 	 k=K;
    for (int i=1;i<n;i++)
    {
        int x = H[i][0];
        int y = H[i][1];
        int w = L[i];
        x++;
        y++;
        adj[x].push_back({y,w});
        adj[y].push_back({x,w});
    }
    for (int i=1;i<maxk;i++)cnt[i]=inf;
    solve(1);
    if (ans==inf)return -1;
    else return ans;
 
}

Compilation message

race.cpp: In function 'void cal(int, int, bool, int, int)':
race.cpp:55:29: error: no matching function for call to 'max(long long int&, int&)'
   55 |     mxdis=max(mxdis,distance);
      |                             ^
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:8:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr 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:
race.cpp:55:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   55 |     mxdis=max(mxdis,distance);
      |                             ^
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:8:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr 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:
race.cpp:55:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   55 |     mxdis=max(mxdis,distance);
      |                             ^
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:8:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _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:
race.cpp:55:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |     mxdis=max(mxdis,distance);
      |                             ^
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:8:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _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:
race.cpp:55:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |     mxdis=max(mxdis,distance);
      |                             ^
race.cpp:56:54: error: no matching function for call to 'min(long long int&, int&)'
   56 |     if (filling)cnt[distance]=min(cnt[distance],depth);
      |                                                      ^
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:8:
/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:56:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   56 |     if (filling)cnt[distance]=min(cnt[distance],depth);
      |                                                      ^
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:8:
/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:56:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   56 |     if (filling)cnt[distance]=min(cnt[distance],depth);
      |                                                      ^
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:8:
/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:56:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   56 |     if (filling)cnt[distance]=min(cnt[distance],depth);
      |                                                      ^
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:8:
/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:56:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   56 |     if (filling)cnt[distance]=min(cnt[distance],depth);
      |                                                      ^