HDU1242 Rescue

#include
#include
#include
#include
#include
#include
#include
#include
#include

using namespace std;

int map[211][211];
int n,m;
int x_s,y_s;
int x_e,y_e;

struct node
{
	int x,y;
	int step;
	friend bool operator<(node n1,node n2)
	{
		return n2.step=n || y<0 || y>=m)	return 1;
	if(map[x][y]==1)	return 1;
	return 0;
}

int BFS()
{
	priority_queueq;
	node cur,next;
	int i;


	cur.x=x_s;
	cur.y=y_s;
	cur.step=0;
	map[cur.x][cur.y]=1;
	q.push(cur);
	while(!q.empty())
	{
		cur=q.top();
		q.pop();
		if(cur.x==x_e && cur.y==y_e)	return cur.step;
		for(i=0;i<4;i++)
		{
			next.x=cur.x+dir[i][0];
			next.y=cur.y+dir[i][1];


			if(judge(next.x,next.y))	continue;
			if(map[next.x][next.y]==-1)	next.step=cur.step+2;
			else						next.step=cur.step+1;
			map[next.x][next.y]=1;
			q.push(next);
		}
	}
	return -1;
}

int main()
{
	int ans;
	int i,l;
	char str[211];
	
	while(scanf("%d%d",&n,&m)!=-1)
	{
		memset(map,0,sizeof(map));


		for(i=0;i

你可能感兴趣的:(HDU1242 Rescue)