Submission #9158

# Submission time Handle Problem Language Result Execution time Memory
9158 2014-09-28T04:11:10 Z myungwoo Your life (kriii2_Y) C++14
4 / 4
56 ms 4992 KB
#include<stdio.h>

int n, m, dist[222222];
int top[111111], endp[222222], prv[222222], ecn;
int fr, rr, que[222222];

int main(){
	int i, s, e;
	scanf("%d%d", &n, &m);
	for(i=1; i<=n; i++)top[i]=-1, dist[i]=-1;
	for(i=0; i<m; i++){
		scanf("%d%d", &s, &e);
		endp[ecn]=e, prv[ecn]=top[s], top[s]=ecn++;
	}
	que[rr++]=1, dist[1]=0;
	for(;fr<rr;fr++){
		s=que[fr];
		for(i=top[s]; i>=0; i=prv[i]){
			e=endp[i];
			if(dist[e]==-1){
				dist[e]=dist[s]+1;
				que[rr++]=e;
			}
		}
	}
	printf("%d", dist[n]);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4992 KB Output is correct
2 Correct 0 ms 4992 KB Output is correct
3 Correct 0 ms 4992 KB Output is correct
4 Correct 0 ms 4992 KB Output is correct
5 Correct 0 ms 4992 KB Output is correct
6 Correct 0 ms 4992 KB Output is correct
7 Correct 0 ms 4992 KB Output is correct
8 Correct 0 ms 4992 KB Output is correct
9 Correct 0 ms 4992 KB Output is correct
10 Correct 20 ms 4992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4992 KB Output is correct
2 Correct 20 ms 4992 KB Output is correct
3 Correct 40 ms 4992 KB Output is correct
4 Correct 40 ms 4992 KB Output is correct
5 Correct 36 ms 4992 KB Output is correct
6 Correct 24 ms 4992 KB Output is correct
7 Correct 28 ms 4992 KB Output is correct
8 Correct 56 ms 4992 KB Output is correct
9 Correct 32 ms 4992 KB Output is correct
10 Correct 48 ms 4992 KB Output is correct