Submission #16608

#TimeUsernameProblemLanguageResultExecution timeMemory
16608eaststarYour life (kriii2_Y)C++14
4 / 4
95 ms4064 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...