Because each time can only go 2 k times stalk, so we first deal with except those points can be directly through the walk (that is, the length of 2 K-th side) can walk, realize well, a bit similar Floyd run transitive closure maintenance accessibility, and then casually run a shortest circuit data so small Floyd bubble a good, The only pit point is, I'm actually a map.
#include <cstdio>
#include <cstring>
#include <iostream>
#define MAXN 10020
Define LL long
using namespace std;
LL n,m,g[55][55],mat[70][55][55];
int main () {
scanf ("%lld%lld", &n,&m);
for (ll i=1;i<=n;i++) for
(ll j=1;j<=n;j++) G[i][j]=1e17;
for (LL a,b,i=1;i<=m;i++) {
scanf ("%lld%lld", &a,&b);
Mat[0][a][b]=1;
g[a][b]=1;
}
for (LL-p=1;p<=64;p++) for (LL-i=1;i<=n;i++) for (LL-j=1;j<=n;j++) for (ll
k=1;k<=n;k++)
if (Mat[p-1][i][k]&&mat[p-1][k][j]) {
mat[p][i][j]=1;
g[i][j]=1;
}
for (ll k=1;k<=n;k++) {for (ll
i=1;i<=n;i++) {for
(ll j=1;j<=n;j++) {
g[i][j]=min (g[i][j],g[i ][K]+G[K][J]);
}} printf ("%lld", G[1][n]);
return 0;
}