답안 #60808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60808 2018-07-24T17:18:13 Z theknife2001 경주 (Race) (IOI11_race) C++17
31 / 100
432 ms 133892 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);
        for(int i=0;i<=K-c;i++)
        {
            temp=k[v][i];
            k[u][i+c]=min(k[u][i+c],temp+1);
        }
    }
    b=min(b,k[u][K]);
}

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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5112 KB Output is correct
2 Correct 9 ms 5192 KB Output is correct
3 Correct 7 ms 5192 KB Output is correct
4 Correct 6 ms 5296 KB Output is correct
5 Correct 8 ms 5296 KB Output is correct
6 Correct 6 ms 5296 KB Output is correct
7 Correct 8 ms 5296 KB Output is correct
8 Correct 8 ms 5300 KB Output is correct
9 Correct 8 ms 5304 KB Output is correct
10 Correct 7 ms 5308 KB Output is correct
11 Correct 8 ms 5312 KB Output is correct
12 Correct 8 ms 5344 KB Output is correct
13 Correct 8 ms 5344 KB Output is correct
14 Correct 7 ms 5352 KB Output is correct
15 Correct 8 ms 5352 KB Output is correct
16 Correct 8 ms 5356 KB Output is correct
17 Correct 8 ms 5404 KB Output is correct
18 Correct 7 ms 5408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5112 KB Output is correct
2 Correct 9 ms 5192 KB Output is correct
3 Correct 7 ms 5192 KB Output is correct
4 Correct 6 ms 5296 KB Output is correct
5 Correct 8 ms 5296 KB Output is correct
6 Correct 6 ms 5296 KB Output is correct
7 Correct 8 ms 5296 KB Output is correct
8 Correct 8 ms 5300 KB Output is correct
9 Correct 8 ms 5304 KB Output is correct
10 Correct 7 ms 5308 KB Output is correct
11 Correct 8 ms 5312 KB Output is correct
12 Correct 8 ms 5344 KB Output is correct
13 Correct 8 ms 5344 KB Output is correct
14 Correct 7 ms 5352 KB Output is correct
15 Correct 8 ms 5352 KB Output is correct
16 Correct 8 ms 5356 KB Output is correct
17 Correct 8 ms 5404 KB Output is correct
18 Correct 7 ms 5408 KB Output is correct
19 Correct 8 ms 5408 KB Output is correct
20 Correct 9 ms 5408 KB Output is correct
21 Incorrect 11 ms 5804 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5112 KB Output is correct
2 Correct 9 ms 5192 KB Output is correct
3 Correct 7 ms 5192 KB Output is correct
4 Correct 6 ms 5296 KB Output is correct
5 Correct 8 ms 5296 KB Output is correct
6 Correct 6 ms 5296 KB Output is correct
7 Correct 8 ms 5296 KB Output is correct
8 Correct 8 ms 5300 KB Output is correct
9 Correct 8 ms 5304 KB Output is correct
10 Correct 7 ms 5308 KB Output is correct
11 Correct 8 ms 5312 KB Output is correct
12 Correct 8 ms 5344 KB Output is correct
13 Correct 8 ms 5344 KB Output is correct
14 Correct 7 ms 5352 KB Output is correct
15 Correct 8 ms 5352 KB Output is correct
16 Correct 8 ms 5356 KB Output is correct
17 Correct 8 ms 5404 KB Output is correct
18 Correct 7 ms 5408 KB Output is correct
19 Correct 195 ms 52680 KB Output is correct
20 Correct 263 ms 54140 KB Output is correct
21 Correct 191 ms 55596 KB Output is correct
22 Correct 215 ms 57084 KB Output is correct
23 Correct 174 ms 58700 KB Output is correct
24 Correct 167 ms 60140 KB Output is correct
25 Correct 184 ms 65608 KB Output is correct
26 Correct 138 ms 71576 KB Output is correct
27 Correct 347 ms 111076 KB Output is correct
28 Correct 432 ms 132220 KB Output is correct
29 Correct 409 ms 133892 KB Output is correct
30 Correct 360 ms 133892 KB Output is correct
31 Correct 344 ms 133892 KB Output is correct
32 Correct 420 ms 133892 KB Output is correct
33 Correct 391 ms 133892 KB Output is correct
34 Correct 362 ms 133892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5112 KB Output is correct
2 Correct 9 ms 5192 KB Output is correct
3 Correct 7 ms 5192 KB Output is correct
4 Correct 6 ms 5296 KB Output is correct
5 Correct 8 ms 5296 KB Output is correct
6 Correct 6 ms 5296 KB Output is correct
7 Correct 8 ms 5296 KB Output is correct
8 Correct 8 ms 5300 KB Output is correct
9 Correct 8 ms 5304 KB Output is correct
10 Correct 7 ms 5308 KB Output is correct
11 Correct 8 ms 5312 KB Output is correct
12 Correct 8 ms 5344 KB Output is correct
13 Correct 8 ms 5344 KB Output is correct
14 Correct 7 ms 5352 KB Output is correct
15 Correct 8 ms 5352 KB Output is correct
16 Correct 8 ms 5356 KB Output is correct
17 Correct 8 ms 5404 KB Output is correct
18 Correct 7 ms 5408 KB Output is correct
19 Correct 8 ms 5408 KB Output is correct
20 Correct 9 ms 5408 KB Output is correct
21 Incorrect 11 ms 5804 KB Output isn't correct
22 Halted 0 ms 0 KB -