Submission #132956

# Submission time Handle Problem Language Result Execution time Memory
132956 2019-07-20T02:48:13 Z StevenH Race (IOI11_race) C++14
21 / 100
35 ms 2936 KB
#include "race.h"
const int maxn=1005;
struct Edge{
	int to,dis,next;
}edge[2005];
int head[maxn],edge_num;
void addedge(int from,int to,int dis)
{
	edge[++edge_num].to=to;
	edge[edge_num].dis=dis;
	edge[edge_num].next=head[from];
	head[from]=edge_num;
}
int LL[maxn],KK;
int m;
bool vis[maxn];
int p,l,ans;
void dfs(int x)
{
	if(l>KK)return;
	if(l==KK)
	{
		if(p<ans)ans=p;
		return;
	}
	for(int i=head[x];i;i=edge[i].next)
	{
		int v=edge[i].to;
		if(!vis[v])
		{
			vis[v]=true;
			l+=edge[i].dis;
			p++;
			dfs(v);
			p--;
			l-=edge[i].dis;
			vis[v]=false;
		}
	}	
	return ;
}


int best_path(int N, int K, int H[][2], int L[])
{
	KK=K;
	ans=N+1;
	for(int i=0;i<N-1;i++)
	{
		addedge(H[i][0],H[i][1],L[i]);
		addedge(H[i][1],H[i][0],L[i]);
	}
	for(int i=0;i<N;i++)
	{
		p=0;
		l=0;
		vis[i]=true;
		dfs(i);
		vis[i]=false;
	}
	if(ans==N+1)return -1;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 13 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 380 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 14 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 7 ms 448 KB Output is correct
29 Correct 11 ms 452 KB Output is correct
30 Correct 13 ms 376 KB Output is correct
31 Correct 14 ms 448 KB Output is correct
32 Correct 14 ms 376 KB Output is correct
33 Correct 14 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 10 ms 376 KB Output is correct
38 Correct 12 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Runtime error 35 ms 2936 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 13 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 380 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 14 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 7 ms 448 KB Output is correct
29 Correct 11 ms 452 KB Output is correct
30 Correct 13 ms 376 KB Output is correct
31 Correct 14 ms 448 KB Output is correct
32 Correct 14 ms 376 KB Output is correct
33 Correct 14 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 10 ms 376 KB Output is correct
38 Correct 12 ms 376 KB Output is correct
39 Runtime error 35 ms 2936 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Halted 0 ms 0 KB -