成都网站改版公司,微信营销手机网站模板,上海科技公司,谁有那种手机网站题目#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid1242这题目就是个大坑#xff0c;先说下思路就是在遇到‘x’时要多停留1步#xff0c;另外就是要用到优先队列#xff0c;要从小到大排列#xff0c;另外就是普通的bfs了 但是要注意题里的each of Angels frien…题目http://acm.hdu.edu.cn/showproblem.php?pid1242 这题目就是个大坑先说下思路就是在遇到‘x’时要多停留1步另外就是要用到优先队列要从小到大排列另外就是普通的bfs了 但是要注意题里的each of Angels friend数据里其实就一个‘r’的位置但我当多个‘r’做应该也没错就是wa想不通啊 这是我按一个‘r’做的。 #includestdio.h
#includestring.h
#include iostream
#include queue
using namespace std;
struct in
{char b;int x;int y;int t;friend bool operator (in a, in b){return a.t b.t; }
};int x, y, m, n;;
char a[205][205],map[205][205];
int dir[4][2]{{1,0},{0,1},{-1,0},{0,-1}};
priority_queueinp;
int bfs(int xx,int yy)
{ if(xxxyyy)return 0;in tt,next;tt.xxx;tt.yyy;tt.ba[xx][yy];tt.t0;p.push(tt);while(!p.empty()){ttp.top();p.pop();a[tt.x][tt.y]#;if(tt.xxtt.yy){return tt.t;}for(int i 0; i 4; i){next.xtt.xdir[i][0];next.ytt.ydir[i][1];next.ttt.t1;if(a[next.x][next.y]x)next.t;if(a[next.x][next.y]!# next.x n next.x0next.ymnext.y0)p.push(next);}}return -1;
}
int main()
{while(~scanf(%d%d, n, m)){int x1, y1;memset(map,0,sizeof(map));memset(a,0,sizeof(a));for(int i 0; i n; i){getchar();for(int j 0; j m; j){scanf(%c,a[i][j]);map[i][j]a[i][j];if(a[i][j]r){x1i;y1j;}if(a[i][j]a){x i;y j;}}} int ans1000000;int u;ubfs(x1,y1);ansu;if(ans-1)printf(Poor ANGEL has to stay in the prison all his life.\n);elseprintf(%d\n,ans);while(!p.empty()){p.pop();}}return 0;
} View Code 转载于:https://www.cnblogs.com/Arthas0v0/p/3456244.html