# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
16608 |
2015-08-29T13:15:52 Z |
eaststar |
Your life (kriii2_Y) |
C++14 |
|
95 ms |
4064 KB |
#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 |
1 |
Correct |
0 ms |
4064 KB |
Output is correct |
2 |
Correct |
0 ms |
4064 KB |
Output is correct |
3 |
Correct |
0 ms |
4064 KB |
Output is correct |
4 |
Correct |
0 ms |
4064 KB |
Output is correct |
5 |
Correct |
0 ms |
4064 KB |
Output is correct |
6 |
Correct |
0 ms |
4064 KB |
Output is correct |
7 |
Correct |
0 ms |
4064 KB |
Output is correct |
8 |
Correct |
0 ms |
4064 KB |
Output is correct |
9 |
Correct |
0 ms |
4064 KB |
Output is correct |
10 |
Correct |
19 ms |
4064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4064 KB |
Output is correct |
2 |
Correct |
28 ms |
4064 KB |
Output is correct |
3 |
Correct |
0 ms |
4064 KB |
Output is correct |
4 |
Correct |
27 ms |
4064 KB |
Output is correct |
5 |
Correct |
57 ms |
4064 KB |
Output is correct |
6 |
Correct |
0 ms |
4064 KB |
Output is correct |
7 |
Correct |
30 ms |
4064 KB |
Output is correct |
8 |
Correct |
41 ms |
4064 KB |
Output is correct |
9 |
Correct |
40 ms |
4064 KB |
Output is correct |
10 |
Correct |
95 ms |
4064 KB |
Output is correct |