QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#178506#2002. RaceModyKachef#Compile Error//C++20829b2023-09-14 01:53:572024-07-04 01:56:29

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:56:29]
  • 评测
  • [2023-09-14 01:53:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define A first
#define B second
#define pii pair<int , int>
#define pb push_back

vector<vector<pii>> adj;
int n , k;
int dfs(int node , int par , int dep){
    if (dep == k) return 0;
    int ans = 1e18;
    for (auto i : adj[node]){
        if (i.A!=par){
            ans = min(ans , dfs(i.A , node , dep + i.B)+1);
        }
    }
    return ans;
}
int best_path(int N , int K , int H[][2] , int L[]){
    n = N; k = K;
    adj.resize(n+1);
    for (int i = 0 ; i<n-1 ; i++){
        adj[H[i][0]].pb({H[i][1] , L[i]});
        adj[H[i][1]].pb({H[i][0] , L[i]});
    }
    int ans = 1e18;
    for (int i = 1 ; i<=n ; i++){
        ans = min(ans , dfs(i , -1 , 0));
    }
    if (ans == 1e18) return -1;
    else return ans;
}

详细

/usr/bin/ld: /tmp/cc1B9gw0.o: in function `main':
implementer.cpp:(.text.startup+0x25): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status