Submission #1100321

# Submission time Handle Problem Language Result Execution time Memory
1100321 2024-10-13T13:44:20 Z vjudge1 Race (IOI11_race) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <array>
using namespace std;
int k,dp[200000];
vector<pair<int,int>>v[200000];
int dfs(int x,int s)
{
    if(s>k||dp[x])return -1;
    else if(s==k)return 0;
    int sm=-1;
    dp[x]=1;
    for(auto [i,vl]:v[x])
    {
        int sl=dfs(i,s+vl);
        if(sl!=-1)
        {
            if(sm==-1)sm=sl+1;
            else
            {
                sm=min(sl+1,sm);
            }
        }
    }
    dp[x]=0;
    return sm;
}
int best_path(int n, int K, int h[][2], int l[])
{
    k=K;
    for(int x=0;x<n-1;x++)
    {
        v[h[x][0]].push_back({h[x][1],l[x]});
        v[h[x][1]].push_back({h[x][0],l[x]});
    }
    if(n<=1000)
    {
        int ans=-1;
        for(int x=0;x<n;x++)
        {
            int s=dfs(x,0);
            if(s!=-1)
            {
                if(ans==-1)ans=s;
                else
                {
                    ans=min(ans,s);
                }
            }
        }
        return ans;
    }
    else
    {
        return 0;
    }
}
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n][2],l[n];
    for(int x=0;x<n-1;x++)
    {
        cin>>h[x][0]>>h[x][1]>>l[x];
    }
    cout<<best_path(n,k,h,l);
}

Compilation message

/usr/bin/ld: /tmp/ccTgseJa.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccOQHYF7.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status