Submission #8854

#TimeUsernameProblemLanguageResultExecution timeMemory
8854gs13068Your life (kriii2_Y)C++98
4 / 4
80 ms9844 KiB
#include<cstdio> #include<vector> std::vector<int> a[200001]; int d[200001]; int main() { int n,m; int i,j,x,y; scanf("%d%d",&n,&m); for(i=1;i<=m;i++) { scanf("%d%d",&x,&y); a[x].push_back(y); } for(i=1;i<=n;i++)d[i]=2e9; d[1]=0; for(i=1;i<=n;i++)for(j=0;j<a[i].size();j++)if(d[a[i][j]]>d[i]+1)d[a[i][j]]=d[i]+1; printf("%d",d[n]<1e9?d[n]:-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...