| 61 | } |
| 62 | } |
| 63 | int main() |
| 64 | { |
| 65 | ios_base::sync_with_stdio(false);//this works only |
| 66 | cin.tie(NULL);// when first all inputs are from user |
| 67 | cout.tie(NULL);//you will see all outputs afterwards |
| 68 | cin>>n>>k; |
| 69 | memset(visited,false,sizeof(visited)); |
| 70 | memset(d,-1,sizeof(d)); |
| 71 | cin>>r; |
| 72 | for(int i=0;i<r;i++) |
| 73 | { |
| 74 | cin>>a[i]; |
| 75 | } |
| 76 | bfs(n); |
| 77 | cout<<d[k]; |
| 78 | return 0; |
| 79 | } |