Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
121501 | 吴悠 | 人际关系 | C++ | 解答错误 | 0 | 1 MS | 264 KB | 524 | 2024-01-21 21:03:33 |
#include<iostream> #include<queue> using namespace std; bool f[101][101],flag[101]; queue<int> q; int main(){ int n,a,b,ans=0;; cin>>n>>a>>b; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cin>>f[i][j]; } } q.push(a); flag[a]=true; while(q.empty()==false){ int front=q.front(); if(front==b){ cout<<ans-1<<endl; exit(0); } ans++; q.pop(); for(int i=1;i<=n;i++){ if(f[front][i]==true && flag[i]==false){ q.push(i); flag[i]=true; } } } return 0; }