Submission #60784

# Submission time Handle Problem Language Result Execution time Memory
60784 2018-07-24T16:48:05 Z theknife2001 Race (IOI11_race) C++17
0 / 100
9 ms 5076 KB
#include "race.h"
#include <bits/stdc++.h>

using namespace std;
const int N=2e5+55;
vector < pair < int , int > > vec[N];
int k[N][105];

void dfs(int u , int p , int K)
{
    int v,c;
    int temp;
    for(auto x:vec[u])
    {
        v=x.first;
        c=x.second;
        if(v==p)
            continue ;
        dfs(v,u,K);
        for(int i=0;i<=K-c;i++)
        {
            temp=k[v][i];
            k[u][i+c]=min(k[u][i+c],temp+1);
        }
    }
}

int best_path(int n, int K, int H[][2], int L[])
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<K;j++)
            k[i][j]=1e9+55;
    }
    for(int i=0;i<n-1;i++)
    {
        vec[H[i][0]].push_back({H[i][1],L[i]});
        vec[H[i][1]].push_back({H[i][0],L[i]});
    }
    int b=1e9+55;
    for(int i=0;i<n;i++)
        b=min(b,k[i][K]);
    return (b==1e9+55?-1:b);
}

# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 5076 KB Output isn't correct
2 Halted 0 ms 0 KB -