답안 #471231

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471231 2021-09-07T19:10:38 Z PiejanVDC 경주 (Race) (IOI11_race) C++17
21 / 100
3000 ms 28748 KB
#include "race.h"
#include <bits/stdc++.h>
using namespace std;

int k, sum, cnt, best=INT_MAX;
vector<pair<int,int>>adj[1000000];

void dfs(int node, int e) {
	if(sum == k) {
		best=min(best,cnt);
		return;
	}
	for(auto a : adj[node]) {
		if(a.first == e || sum+a.second > k) continue;
		sum+=a.second;
		cnt++;
		dfs(a.first,node);
		cnt--;
		sum-=a.second;
	}
}

int best_path(int N, int K,int H[][2],int L[]) {
	k=K;
	for(int i = 0 ; i < N-1 ; i++) {
		adj[H[i][0]].push_back({H[i][1],L[i]});
		adj[H[i][1]].push_back({H[i][0],L[i]});
	}
	for(int root = 0 ; root < N ; root++) {
		sum=0;
		cnt=0;
		dfs(root,-1);
	}
	return (best==INT_MAX?-1:best);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 16 ms 23756 KB Output is correct
3 Correct 15 ms 23688 KB Output is correct
4 Correct 15 ms 23728 KB Output is correct
5 Correct 15 ms 23780 KB Output is correct
6 Correct 15 ms 23724 KB Output is correct
7 Correct 15 ms 23756 KB Output is correct
8 Correct 15 ms 23780 KB Output is correct
9 Correct 15 ms 23756 KB Output is correct
10 Correct 16 ms 23760 KB Output is correct
11 Correct 15 ms 23752 KB Output is correct
12 Correct 16 ms 23756 KB Output is correct
13 Correct 15 ms 23784 KB Output is correct
14 Correct 15 ms 23768 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
16 Correct 15 ms 23756 KB Output is correct
17 Correct 16 ms 23732 KB Output is correct
18 Correct 16 ms 23676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 16 ms 23756 KB Output is correct
3 Correct 15 ms 23688 KB Output is correct
4 Correct 15 ms 23728 KB Output is correct
5 Correct 15 ms 23780 KB Output is correct
6 Correct 15 ms 23724 KB Output is correct
7 Correct 15 ms 23756 KB Output is correct
8 Correct 15 ms 23780 KB Output is correct
9 Correct 15 ms 23756 KB Output is correct
10 Correct 16 ms 23760 KB Output is correct
11 Correct 15 ms 23752 KB Output is correct
12 Correct 16 ms 23756 KB Output is correct
13 Correct 15 ms 23784 KB Output is correct
14 Correct 15 ms 23768 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
16 Correct 15 ms 23756 KB Output is correct
17 Correct 16 ms 23732 KB Output is correct
18 Correct 16 ms 23676 KB Output is correct
19 Correct 15 ms 23780 KB Output is correct
20 Correct 16 ms 23688 KB Output is correct
21 Correct 28 ms 23792 KB Output is correct
22 Correct 16 ms 23756 KB Output is correct
23 Correct 16 ms 23852 KB Output is correct
24 Correct 17 ms 23884 KB Output is correct
25 Correct 28 ms 23856 KB Output is correct
26 Correct 15 ms 23800 KB Output is correct
27 Correct 16 ms 23756 KB Output is correct
28 Correct 19 ms 23756 KB Output is correct
29 Correct 23 ms 23796 KB Output is correct
30 Correct 24 ms 23756 KB Output is correct
31 Correct 28 ms 23780 KB Output is correct
32 Correct 28 ms 23852 KB Output is correct
33 Correct 27 ms 23848 KB Output is correct
34 Correct 16 ms 23756 KB Output is correct
35 Correct 16 ms 23792 KB Output is correct
36 Correct 18 ms 23776 KB Output is correct
37 Correct 23 ms 23848 KB Output is correct
38 Correct 27 ms 23816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 16 ms 23756 KB Output is correct
3 Correct 15 ms 23688 KB Output is correct
4 Correct 15 ms 23728 KB Output is correct
5 Correct 15 ms 23780 KB Output is correct
6 Correct 15 ms 23724 KB Output is correct
7 Correct 15 ms 23756 KB Output is correct
8 Correct 15 ms 23780 KB Output is correct
9 Correct 15 ms 23756 KB Output is correct
10 Correct 16 ms 23760 KB Output is correct
11 Correct 15 ms 23752 KB Output is correct
12 Correct 16 ms 23756 KB Output is correct
13 Correct 15 ms 23784 KB Output is correct
14 Correct 15 ms 23768 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
16 Correct 15 ms 23756 KB Output is correct
17 Correct 16 ms 23732 KB Output is correct
18 Correct 16 ms 23676 KB Output is correct
19 Execution timed out 3067 ms 28748 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 16 ms 23756 KB Output is correct
3 Correct 15 ms 23688 KB Output is correct
4 Correct 15 ms 23728 KB Output is correct
5 Correct 15 ms 23780 KB Output is correct
6 Correct 15 ms 23724 KB Output is correct
7 Correct 15 ms 23756 KB Output is correct
8 Correct 15 ms 23780 KB Output is correct
9 Correct 15 ms 23756 KB Output is correct
10 Correct 16 ms 23760 KB Output is correct
11 Correct 15 ms 23752 KB Output is correct
12 Correct 16 ms 23756 KB Output is correct
13 Correct 15 ms 23784 KB Output is correct
14 Correct 15 ms 23768 KB Output is correct
15 Correct 15 ms 23756 KB Output is correct
16 Correct 15 ms 23756 KB Output is correct
17 Correct 16 ms 23732 KB Output is correct
18 Correct 16 ms 23676 KB Output is correct
19 Correct 15 ms 23780 KB Output is correct
20 Correct 16 ms 23688 KB Output is correct
21 Correct 28 ms 23792 KB Output is correct
22 Correct 16 ms 23756 KB Output is correct
23 Correct 16 ms 23852 KB Output is correct
24 Correct 17 ms 23884 KB Output is correct
25 Correct 28 ms 23856 KB Output is correct
26 Correct 15 ms 23800 KB Output is correct
27 Correct 16 ms 23756 KB Output is correct
28 Correct 19 ms 23756 KB Output is correct
29 Correct 23 ms 23796 KB Output is correct
30 Correct 24 ms 23756 KB Output is correct
31 Correct 28 ms 23780 KB Output is correct
32 Correct 28 ms 23852 KB Output is correct
33 Correct 27 ms 23848 KB Output is correct
34 Correct 16 ms 23756 KB Output is correct
35 Correct 16 ms 23792 KB Output is correct
36 Correct 18 ms 23776 KB Output is correct
37 Correct 23 ms 23848 KB Output is correct
38 Correct 27 ms 23816 KB Output is correct
39 Execution timed out 3067 ms 28748 KB Time limit exceeded
40 Halted 0 ms 0 KB -