设为首页 加入收藏

TOP

nyist 284 && poj 2312 坦克大战(变形BFS)
2014-11-23 20:16:25 来源: 作者: 【 】 浏览:6
Tags:nyist 284 poj 2312 坦克 大战 变形 BFS

题目大意:这个题是以坦克大战为原型出来的题目,就是走迷宫的变种,给定一个地图mxn的地图,地图上有普通的砖B,金砖S,河R,空地E,和一个宝物位置T,和你的位置Y,求吃到宝物的最小步数(坦克通过普通砖B需要两步,空地E一步,不能通过金砖和河)..

#include 
#include 
using namespace std;
int n,m;
int mintime[305][305];
char map[305][305];
struct point
{
	int x,y,time;
}s,e;
int h[4][2]={1,0,-1,0,0,-1,0,1};
queue q;
int bfs(point s)
{
	int i,j,x,y; point t,tt;
	while(!q.empty()) q.pop();
	q.push(s); mintime[s.x][s.y]=0;
	while(!q.empty())
	{
		t=q.front(); q.pop();
		for(i=0;i<4;i++)
		{
			x=t.x+h[i][0]; y=t.y+h[i][1];
			if(x>=0&&x=0&&y>n>>m&&(n+m))
	{
		for(i=0;i>map[i][j]; mintime[i][j]=100000005;
			if(map[i][j]=='Y') { s.x=i;  s.y=j; s.time=0;}
			if(map[i][j]=='T') { e.x=i;  e.y=j;}
		}
		int ans=bfs(s);
		if(ans<100000005) cout< 
 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇libprotobuf ERROR google/protob.. 下一篇hdu 2104

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·微服务 Spring Boot (2025-12-26 18:20:10)
·如何调整 Redis 内存 (2025-12-26 18:20:07)
·MySQL 数据类型:从 (2025-12-26 18:20:03)
·Linux Shell脚本教程 (2025-12-26 17:51:10)
·Qt教程,Qt5编程入门 (2025-12-26 17:51:07)