Submission #60796

# Submission time Handle Problem Language Result Execution time Memory
60796 2018-07-24T17:03:02 Z theknife2001 Race (IOI11_race) C++17
0 / 100
8 ms 5112 KB
#include "race.h"
#include <bits/stdc++.h>

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

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++)
        {
            b=min(b,k[v][i]+k[u][K-i-c]+1);
            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=1;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]});
    }
    dfs(0,-1,K);
    return (b==1e9+55?-1:b);
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -