原网址
广度搜索 比较麻烦的地方是加了一个查克拉,用book数组标记的时候将查克拉加上就ok 记得当时做的时候废了好长时间
两种方法,不多bb
AC代码
三维数组标记的
#include<stdio.h>
#include<string.h>
struct node
{
int x,y,step,num;
}q[40002];
int m,n,ck,sx,sy;
char map[202][202];
int book[202][202][20];
void bfs()
{
memset(book,0,sizeof(book));
int tx,ty,tz,head,tail;
int dir[4][2]={
0,1,0,-1,1,0,-1,0};
head=tail=1;
q[1].x=sx,q[1].y=sy,q[1].num=ck;q[1].step=0;
book[sx][sy][ck]=1;
tail++;
while(head<tail)
{
for(int i=0; i<4; i++)
{
int tx=q[head].x+dir[i][0];
int ty=q[head].y+dir[i