제출 #1147416

#제출 시각아이디문제언어결과실행 시간메모리
1147416aminjon__경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define endl '\n'
typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;

#include "race.h"
int best_path(int N, int K, int H[][2], int L[])
{
    vector<vector<pair<ll,ll>>>rebr(N+1);
    for(int i = 0;i < N-1;i++){
        rebr[H[i][0]].push_back({H[i][1],L[i]});
        rebr[H[i][1]].push_back({H[i][0],L[i]});
    }
    ll ans = LLONG_MAX;
    auto dfs =[&](ll x , ll p , ll sum , ll depth , auto &&dfs){
        
        set< pair<ll,ll> > Suffix;  
        Suffix.insert({sum , depth});
        for(auto g: rebr[x]){
            if(g.first==p)continue;
            
            auto govno = dfs(g , x , sum+g.second ,depth+1, dfs);
            
            if(Suffix.size() < govno.size()){
                swap(govno, Suffix);
            }
            for(auto g: govno){
                Suffix.insert(g);
            }
        }
        
        for(auto g: Suffix){
            if(g.first == sum+K){
                ans = min(g.second-depth ,ans);
                continue;
            }
            auto r = Suffix.upper_bound({sum+sum+K - g.first , 0});
            if(r != Suffix.end()){
                ans = min(ans , g.second+r->second - (depth*2) );
            }
            
        }
        
        return Suffix;
    };
    dfs(1 , 0 , 0 , 0 , dfs);
    
    
    
    
    
  return (ans == LLONG_MAX ? -1 : ans);
}


signed main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  
  return 0;
}

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

race.cpp: In instantiation of 'best_path(int, int, int (*)[2], int*)::<lambda(ll, ll, ll, ll, auto:23&&)> [with auto:23 = best_path(int, int, int (*)[2], int*)::<lambda(ll, ll, ll, ll, auto:23&&)>&; ll = long long int]':
race.cpp:50:8:   required from here
race.cpp:26:29: error: no match for call to '(best_path(int, int, int (*)[2], int*)::<lambda(ll, ll, ll, ll, auto:23&&)>) (std::pair<long long int, long long int>&, ll&, ll, ll, best_path(int, int, int (*)[2], int*)::<lambda(ll, ll, ll, ll, auto:23&&)>&)'
   26 |             auto govno = dfs(g , x , sum+g.second ,depth+1, dfs);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:19:15: note: candidate: 'template<class auto:23> best_path(int, int, int (*)[2], int*)::<lambda(ll, ll, ll, ll, auto:23&&)>'
   19 |     auto dfs =[&](ll x , ll p , ll sum , ll depth , auto &&dfs){
      |               ^
race.cpp:19:15: note:   template argument deduction/substitution failed:
race.cpp:26:30: note:   cannot convert 'g' (type 'std::pair<long long int, long long int>') to type 'll' {aka 'long long int'}
   26 |             auto govno = dfs(g , x , sum+g.second ,depth+1, dfs);
      |                              ^