# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
9158 | myungwoo | Your life (kriii2_Y) | C++14 | 56 ms | 4992 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |