답안 #914463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914463 2024-01-22T08:07:03 Z Isaac_Q1 경주 (Race) (IOI11_race) C++14
21 / 100
3000 ms 13652 KB
#include <bits/stdc++.h>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
#define pii pair<int, ll>
#define ll long long
using namespace std;
ll TARGET;
const int INF = 1e9;
int BEST;
 
vector<vector<pii>> graph;
 
void DFS(int p, int node, ll w, int lenght){
    if(w > TARGET) return;
    if(w == TARGET) BEST = min(BEST,lenght);

    for(auto &e: graph[node])
    {
        if(e.first == p) continue;

        DFS(node, e.first, w + e.second, lenght + 1);
    }
}
 
 
int best_path(int N, int K, int H[][2], int L[]){
    graph.assign(N,vector<pii>{});
    TARGET = K;
    int a, b, l;
    for(int i=0; i<N-1; i++)
    {
        a = H[i][0]; b = H[i][1]; l = L[i];
        graph[a].push_back({b,l});
        graph[b].push_back({a,l});
    }

    BEST = INF;

    for(int i=0; i<N-1; i++) DFS(-1,i,0,0);

    if(BEST == INF) return -1;
    return BEST;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2480 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2480 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2500 KB Output is correct
21 Correct 7 ms 2396 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 2 ms 2392 KB Output is correct
25 Correct 9 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 3 ms 2396 KB Output is correct
29 Correct 5 ms 2396 KB Output is correct
30 Correct 6 ms 2396 KB Output is correct
31 Correct 7 ms 2500 KB Output is correct
32 Correct 7 ms 2584 KB Output is correct
33 Correct 7 ms 2396 KB Output is correct
34 Correct 2 ms 2396 KB Output is correct
35 Correct 2 ms 2396 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 6 ms 2432 KB Output is correct
38 Correct 7 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2480 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 2297 ms 13652 KB Output is correct
20 Correct 1891 ms 13648 KB Output is correct
21 Execution timed out 3051 ms 13260 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2480 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2500 KB Output is correct
21 Correct 7 ms 2396 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 2 ms 2392 KB Output is correct
25 Correct 9 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 3 ms 2396 KB Output is correct
29 Correct 5 ms 2396 KB Output is correct
30 Correct 6 ms 2396 KB Output is correct
31 Correct 7 ms 2500 KB Output is correct
32 Correct 7 ms 2584 KB Output is correct
33 Correct 7 ms 2396 KB Output is correct
34 Correct 2 ms 2396 KB Output is correct
35 Correct 2 ms 2396 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 6 ms 2432 KB Output is correct
38 Correct 7 ms 2396 KB Output is correct
39 Correct 2297 ms 13652 KB Output is correct
40 Correct 1891 ms 13648 KB Output is correct
41 Execution timed out 3051 ms 13260 KB Time limit exceeded
42 Halted 0 ms 0 KB -