求 WAR CHESS 求人卫教材激活码码

Problem Description
Sample Input
Sample Output
Y为起始点,MV为移动能量,经过同伴和空地消耗一点能量,经过森林消耗两点,小河三点,如果旁边四格有敌人,能量变为0,而且不能停留在同伴所在的格子,最后输出时将所有能停留的格子变为*
#include &iostream&
#include &stdio.h&
#include &queue&
int dir[4][2]={1,0,-1,0,0,-1,0,1};
char map[101][101];
bool vis[101][101];
struct node
bool operator&( const node &t)const
return t.mv&
bool check(int x,int y)
if(x&=0 && x&n && y&=0 && y&m)
bool ok(int x,int y) //检查邻边
if(check(x-1, y) && map[x-1][y]=='E')
if(check(x+1, y) && map[x+1][y]=='E')
if(check(x, y+1) && map[x][y+1]=='E')
if(check(x, y-1) && map[x][y-1]=='E')
priority_queue&node&q;
q.push(Start);
while (!q.empty())
t=q.top();
for (int i=0; i&4; i++)
temp.x+=dir[i][0];
temp.y+=dir[i][1];
if (check(temp.x, temp.y) && map[temp.x][temp.y]!='#'&& map[temp.x][temp.y]!='E' && !vis[temp.x][temp.y])
if(map[temp.x][temp.y] == '.')
temp.mv--;
else if(map[temp.x][temp.y] == 'T')
temp.mv-=2;
else if(map[temp.x][temp.y] == 'R')
temp.mv-=3;
else if(map[temp.x][temp.y] == 'P')
temp.mv--;
if (temp.mv&0)
if(!ok(temp.x, temp.y))
temp.mv=0;
if(map[temp.x][temp.y]!='P')
map[temp.x][temp.y]='*';
vis[temp.x][temp.y]=1;
if(temp.mv&0)
q.push(temp);
int main()
scanf("%d",&t);
while (t--)
scanf("%d%d%d",&n,&m,&mv);
memset(vis, false, sizeof(vis));
for (int i=0; i&n; i++)
scanf("%s",map[i]);
for (int j=0;j&m; j++)
if(map[i][j]=='Y')
Start.x=i,Start.y=j;
vis[i][j]=1;
for (int i=0; i&n; i++)
printf("%s\n",map[i]);
printf("\n");
HDU3345:War Chess(BFS+优先队列)
hdu4845 BFS
HDU 3345 War Chess
BFS+数组维护
hdu 1732 Push Box(BFS)
HDU 1430 魔板 康托展开或字典树 + BFS
hdu 2579 BFS
没有更多推荐了,

参考资料

 

随机推荐