http://acm.hdu.edu.cn/showproblem.php?pid=1252
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
/*
easy bfs
*/
struct node
{
int x[3];
}p;
int maze[55][55],m,vis[55][55][55];
void set(node t,node tt)
{
vis[t.x[0]][t.x[1]][t.x[2]]=1+vis[tt.x[0]][tt.x[1]][tt.x[2]];
}
int test(node t)
{
return vis[t.x[0]][t.x[1]][t.x[2]];
}
bool ok(node t)
{
return t.x[0]==t.x[1]&&t.x[1]==t.x[2];
}
int bfs()
{
memset(vis,0,sizeof(vis));
node t;
queue<node> que;
if(ok(p))
return 0;
que.push(p);
这篇博客详细介绍了如何解决HDU 1252问题,利用宽度优先搜索(BFS)算法在图上进行徒步旅行。通过C语言实现,解释了算法的思路和步骤,并提供了相关代码示例。
订阅专栏 解锁全文
899

被折叠的 条评论
为什么被折叠?



