1 条题解

  • -1
    @ 2021-11-21 16:31:25

    #include<iostream>
    using namespace std;
    #define N 101
    int n,y,a[N][N],b[N];
    struct node
    {
    int xx,num;
    }h[N];
    void sb(int x)
    {
    int head=0,tail=1;
    h[tail].xx=x;
    h[tail].num=0;
    b[x]=1;
    while(head<tail)
    {
    head++;
    for(int i=1;i<=n;i++)
    {
    if(a[i][h[head].xx]==1&&b[i]==0)
    {
    b[i]=1;
    tail++;
    h[tail].num=h[head].num;
    if(i==y)
    {
    cout<<h[tail].num;
    return;
    }
    h[tail].xx=i;
    h[tail].num++;
    }
    }
    }
    }
    int main()
    {
    int hhh;
    cin>>n>>hhh>>y;
    for(int i=1;i<=n;i++)
    {
    for(int j=1;j<=n;j++)
    {
    cin>>a[i][j];
    }
    }
    sb(hhh+1);
    return 0;
    }

  • 1

关系网络(relationship,1s,64MB)

信息

ID
1006
难度
8
分类
(无)
标签
递交数
25
已通过
4
通过率
16%
上传者