关系网络
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
说明
有n个人,他们的编号为1~n,其中有一些人相互认识,现在x想要认识y,可以通过他所认识的人来认识更多的人(如果a认识b,b认识c,那么a可以通过b来认识c),求出x最少需要通过多少人才能认识y。
输入格式
第1行3个整数n、x、y,2<=n<=100;
接下来的n行是一个n*n的邻接矩阵,a[i][j]=1表示i认识j, a[i][j]=0表示不认识。
保证i=j时,a[i][j]=0,并且a[i][j]= a[j][i]。
输出格式
一行一个整数,表示x认识y最少需要通过的人数。数据保证x一定能认识y。
样例
5 1 5
0 1 0 0 0
1 0 1 1 0
0 1 0 1 0
0 1 1 0 1
0 0 0 1 0
2