Submission #133154

# Submission time Handle Problem Language Result Execution time Memory
133154 2019-07-20T08:08:32 Z tinjyu Race (IOI11_race) C++14
31 / 100
348 ms 178816 KB
#include "race.h"
#include <iostream>
using namespace std;
int tag[200005],road[200005],map[400005][3],n,k;
int a=10000000,ans[200005][205];
int find(int x)
{
	tag[x]=1;
	int g=road[x];
	//cout<<x<<endl;
	while(g!=-1)
	{
		int now=map[g][0];
		if(tag[now]!=1)
		{
			find(now);
			//cout<<x<<" "<<now<<endl;
			for(int i=map[g][2];i<=k;i++)
			{
				a=min(ans[now][i-map[g][2]]+ans[x][k-i]+1,a);
				//cout<<ans[now][i-map[g][2]]<<" "<<ans[x][k-i]<<" "<<k-i-map[g][2]<<"  ";
				
			}
			//cout<<endl;
			for(int i=0;i<=k-map[g][2];i++)ans[x][i+map[g][2]]=min(ans[now][i]+1,ans[x][i+map[g][2]]);
		}
		g=map[g][1];
	}
}
int best_path(int N, int K, int H[][2], int L[])
{
	n=N,k=K;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)ans[i][j]=10000000;
	}
	
	for(int i=0;i<n;i++)
	{
		road[i]=-1;
	}
	for(int i=0;i<n-1;i++)
	{
		int x=H[i][0],y=H[i][1];
		map[i*2][0]=y;
		map[i*2][1]=road[x];
		map[i*2][2]=L[i];
		road[x]=i*2;
		map[i*2+1][0]=x;
		map[i*2+1][1]=road[y];
		map[i*2+1][2]=L[i];
		road[y]=i*2+1;
	}
	find(0);
	for(int i=0;i<n;i++)a=min(ans[i][k],a);
	if(a==10000000)a=-1;
  	return a;
}

Compilation message

race.cpp: In function 'int find(int)':
race.cpp:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# 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 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 376 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 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 376 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 Incorrect 5 ms 1148 KB Output isn't correct
22 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 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 163 ms 84940 KB Output is correct
20 Correct 160 ms 84872 KB Output is correct
21 Correct 161 ms 85112 KB Output is correct
22 Correct 159 ms 84828 KB Output is correct
23 Correct 142 ms 84900 KB Output is correct
24 Correct 138 ms 84984 KB Output is correct
25 Correct 168 ms 87352 KB Output is correct
26 Correct 134 ms 89592 KB Output is correct
27 Correct 300 ms 168568 KB Output is correct
28 Correct 308 ms 178816 KB Output is correct
29 Correct 306 ms 178208 KB Output is correct
30 Correct 316 ms 168452 KB Output is correct
31 Correct 304 ms 168356 KB Output is correct
32 Correct 348 ms 168256 KB Output is correct
33 Correct 334 ms 168744 KB Output is correct
34 Correct 231 ms 168184 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 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 376 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 Incorrect 5 ms 1148 KB Output isn't correct
22 Halted 0 ms 0 KB -