이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct al{
    int e,nx;
}a[200010];
int st[100010],d[100010],t;
int main(){
    int i,j,n,m,s,e;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;++i){
        scanf("%d%d",&s,&e);
        a[++t].nx=st[s],a[t].e=e,st[s]=t;
    }
    for(i=2;i<=n;++i)d[i]=1e9;
    for(i=1;i<=n;++i)if(d[i]<1e9){
        for(j=st[i];j;j=a[j].nx)d[a[j].e]=min(d[a[j].e],d[i]+1);
    }
    if(d[n]==1e9)d[n]=-1;
    printf("%d",d[n]);
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |