답안 #242773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
242773 2020-06-29T09:52:25 Z michao 경주 (Race) (IOI11_race) C++14
21 / 100
3000 ms 12024 KB
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=2e5+5;
const int inf=1e9+9;
vector<pii>P[MAX];
int gle[MAX];
int dist[MAX];
int ans=inf;

void brut(int u,int fa,int k)
{
	if (fa==-1)gle[u]=0,dist[u]=0;
	if (dist[u]==k)ans=min(ans,gle[u]);
	for (auto it:P[u])
	{
		if (it.st!=fa)
		{
			gle[it.st]=gle[u]+1;
			dist[it.st]=dist[u]+it.nd;
			brut(it.st,u,k);
		}
	}
}

void func(int n,int k)
{
	for (int i=1;i<=n;i++)brut(i,-1,k);
	
}

int best_path(int n,int k,int h[][2],int l[])
{
	for (int i=0;i<n-1;i++) 
	P[h[i][0]].pb(mp(h[i][1],l[i])),P[h[i][1]].pb(mp(h[i][0],l[i]));
	func(n,k);
	if (ans==inf)ans=-1;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4992 KB Output is correct
2 Correct 8 ms 5120 KB Output is correct
3 Correct 8 ms 5120 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 8 ms 5024 KB Output is correct
6 Correct 8 ms 5120 KB Output is correct
7 Correct 8 ms 5120 KB Output is correct
8 Correct 8 ms 5120 KB Output is correct
9 Correct 8 ms 4992 KB Output is correct
10 Correct 8 ms 5120 KB Output is correct
11 Correct 8 ms 5120 KB Output is correct
12 Correct 8 ms 4992 KB Output is correct
13 Correct 8 ms 4992 KB Output is correct
14 Correct 9 ms 4992 KB Output is correct
15 Correct 8 ms 4992 KB Output is correct
16 Correct 7 ms 4992 KB Output is correct
17 Correct 7 ms 4992 KB Output is correct
18 Correct 7 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4992 KB Output is correct
2 Correct 8 ms 5120 KB Output is correct
3 Correct 8 ms 5120 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 8 ms 5024 KB Output is correct
6 Correct 8 ms 5120 KB Output is correct
7 Correct 8 ms 5120 KB Output is correct
8 Correct 8 ms 5120 KB Output is correct
9 Correct 8 ms 4992 KB Output is correct
10 Correct 8 ms 5120 KB Output is correct
11 Correct 8 ms 5120 KB Output is correct
12 Correct 8 ms 4992 KB Output is correct
13 Correct 8 ms 4992 KB Output is correct
14 Correct 9 ms 4992 KB Output is correct
15 Correct 8 ms 4992 KB Output is correct
16 Correct 7 ms 4992 KB Output is correct
17 Correct 7 ms 4992 KB Output is correct
18 Correct 7 ms 4992 KB Output is correct
19 Correct 7 ms 4992 KB Output is correct
20 Correct 7 ms 5120 KB Output is correct
21 Correct 25 ms 4992 KB Output is correct
22 Correct 26 ms 5120 KB Output is correct
23 Correct 26 ms 5120 KB Output is correct
24 Correct 24 ms 5120 KB Output is correct
25 Correct 25 ms 5120 KB Output is correct
26 Correct 24 ms 5120 KB Output is correct
27 Correct 25 ms 5120 KB Output is correct
28 Correct 24 ms 5120 KB Output is correct
29 Correct 24 ms 5120 KB Output is correct
30 Correct 25 ms 5120 KB Output is correct
31 Correct 24 ms 5120 KB Output is correct
32 Correct 24 ms 5120 KB Output is correct
33 Correct 27 ms 5120 KB Output is correct
34 Correct 20 ms 5120 KB Output is correct
35 Correct 16 ms 5120 KB Output is correct
36 Correct 15 ms 5120 KB Output is correct
37 Correct 15 ms 5120 KB Output is correct
38 Correct 17 ms 5120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4992 KB Output is correct
2 Correct 8 ms 5120 KB Output is correct
3 Correct 8 ms 5120 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 8 ms 5024 KB Output is correct
6 Correct 8 ms 5120 KB Output is correct
7 Correct 8 ms 5120 KB Output is correct
8 Correct 8 ms 5120 KB Output is correct
9 Correct 8 ms 4992 KB Output is correct
10 Correct 8 ms 5120 KB Output is correct
11 Correct 8 ms 5120 KB Output is correct
12 Correct 8 ms 4992 KB Output is correct
13 Correct 8 ms 4992 KB Output is correct
14 Correct 9 ms 4992 KB Output is correct
15 Correct 8 ms 4992 KB Output is correct
16 Correct 7 ms 4992 KB Output is correct
17 Correct 7 ms 4992 KB Output is correct
18 Correct 7 ms 4992 KB Output is correct
19 Execution timed out 3074 ms 12024 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4992 KB Output is correct
2 Correct 8 ms 5120 KB Output is correct
3 Correct 8 ms 5120 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 8 ms 5024 KB Output is correct
6 Correct 8 ms 5120 KB Output is correct
7 Correct 8 ms 5120 KB Output is correct
8 Correct 8 ms 5120 KB Output is correct
9 Correct 8 ms 4992 KB Output is correct
10 Correct 8 ms 5120 KB Output is correct
11 Correct 8 ms 5120 KB Output is correct
12 Correct 8 ms 4992 KB Output is correct
13 Correct 8 ms 4992 KB Output is correct
14 Correct 9 ms 4992 KB Output is correct
15 Correct 8 ms 4992 KB Output is correct
16 Correct 7 ms 4992 KB Output is correct
17 Correct 7 ms 4992 KB Output is correct
18 Correct 7 ms 4992 KB Output is correct
19 Correct 7 ms 4992 KB Output is correct
20 Correct 7 ms 5120 KB Output is correct
21 Correct 25 ms 4992 KB Output is correct
22 Correct 26 ms 5120 KB Output is correct
23 Correct 26 ms 5120 KB Output is correct
24 Correct 24 ms 5120 KB Output is correct
25 Correct 25 ms 5120 KB Output is correct
26 Correct 24 ms 5120 KB Output is correct
27 Correct 25 ms 5120 KB Output is correct
28 Correct 24 ms 5120 KB Output is correct
29 Correct 24 ms 5120 KB Output is correct
30 Correct 25 ms 5120 KB Output is correct
31 Correct 24 ms 5120 KB Output is correct
32 Correct 24 ms 5120 KB Output is correct
33 Correct 27 ms 5120 KB Output is correct
34 Correct 20 ms 5120 KB Output is correct
35 Correct 16 ms 5120 KB Output is correct
36 Correct 15 ms 5120 KB Output is correct
37 Correct 15 ms 5120 KB Output is correct
38 Correct 17 ms 5120 KB Output is correct
39 Execution timed out 3074 ms 12024 KB Time limit exceeded
40 Halted 0 ms 0 KB -