Submission #1068240

# Submission time Handle Problem Language Result Execution time Memory
1068240 2024-08-21T08:48:13 Z apper Race (IOI11_race) C++17
21 / 100
3000 ms 12124 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long 
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
/*------------------------------------code------------------------------------*/
const ll MAXN=1e5+9;
const ll INF=1e9+9;
const ll R=(1<<18);
const int X=18;
//const ll M=1e9+7;
//const ll P=47;

int n, k;
vector<pair<int, int>> adj[MAXN];
int ans=INF;

void dfs(int v, int p, ll d, int cnt)
{
	if(d==k)
	{
		ans=min(ans, cnt);
		return;
	}
	for(auto [u, w] : adj[v])
	{
		if(u==p || d+w>k || cnt+1>ans)
			continue;
		dfs(u, v, d+w, cnt+1);
	}
}

int best_path(int N, int K, int edges[][2], int weights[]) 
{
	if(k==1) 
		return 0;
	n=N;
	k=K;
	for(int i=0;i<n-1;i++)
	{
		int u = edges[i][0];
		int v = edges[i][1];
		adj[u].pb({v, weights[i]});
		adj[v].pb({u, weights[i]});
	}
	for(int i=1;i<=n;i++)
		dfs(i, -1, 0, 0);
	return (ans==INF ? -1 : ans);
}

/*
int main()
{
    cin.tie(0); ios_base::sync_with_stdio(0);
	solve();
	return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4184 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4184 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2648 KB Output is correct
21 Correct 7 ms 2612 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 2 ms 2652 KB Output is correct
24 Correct 2 ms 2648 KB Output is correct
25 Correct 10 ms 2652 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2692 KB Output is correct
28 Correct 3 ms 2652 KB Output is correct
29 Correct 5 ms 2848 KB Output is correct
30 Correct 4 ms 2652 KB Output is correct
31 Correct 10 ms 2840 KB Output is correct
32 Correct 7 ms 2848 KB Output is correct
33 Correct 7 ms 4188 KB Output is correct
34 Correct 3 ms 2652 KB Output is correct
35 Correct 2 ms 2648 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 6 ms 2856 KB Output is correct
38 Correct 8 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4184 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 484 ms 7480 KB Output is correct
20 Correct 550 ms 7512 KB Output is correct
21 Correct 744 ms 7772 KB Output is correct
22 Correct 1286 ms 7508 KB Output is correct
23 Correct 57 ms 7756 KB Output is correct
24 Correct 45 ms 7504 KB Output is correct
25 Correct 2908 ms 7144 KB Output is correct
26 Execution timed out 3093 ms 12124 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4184 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2648 KB Output is correct
21 Correct 7 ms 2612 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 2 ms 2652 KB Output is correct
24 Correct 2 ms 2648 KB Output is correct
25 Correct 10 ms 2652 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2692 KB Output is correct
28 Correct 3 ms 2652 KB Output is correct
29 Correct 5 ms 2848 KB Output is correct
30 Correct 4 ms 2652 KB Output is correct
31 Correct 10 ms 2840 KB Output is correct
32 Correct 7 ms 2848 KB Output is correct
33 Correct 7 ms 4188 KB Output is correct
34 Correct 3 ms 2652 KB Output is correct
35 Correct 2 ms 2648 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 6 ms 2856 KB Output is correct
38 Correct 8 ms 2652 KB Output is correct
39 Correct 484 ms 7480 KB Output is correct
40 Correct 550 ms 7512 KB Output is correct
41 Correct 744 ms 7772 KB Output is correct
42 Correct 1286 ms 7508 KB Output is correct
43 Correct 57 ms 7756 KB Output is correct
44 Correct 45 ms 7504 KB Output is correct
45 Correct 2908 ms 7144 KB Output is correct
46 Execution timed out 3093 ms 12124 KB Time limit exceeded
47 Halted 0 ms 0 KB -