目录
- 问题
- 解决
- CODE
[传送门]
问题如何在一维数组求最小步数
解决和二维处理一样
但是我sef了
CODE#include
using namespace std;
const int N = 1e5+10;
int dist[N];
int st[N];
int n,k;
void bfs(int x)
{
memset(dist,0,sizeof dist);
queue q;
q.push(x);
st[x] = 1;
dist[x] = 0;
while(!q.empty())
{
int t = q.front();
q.pop();
if(t==k)
{
cout>k;
bfs(n);
}
int main()
{
solve();
return 0;
}