HDOJ 1242 Rescue
来源:互联网 发布:苹果电脑设计软件下载 编辑:程序博客网 时间:2024/05/20 03:46
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1242 int x,y; int step; int time; int i; Q.push(s); point hd; while(!Q.empty()){ hd=Q.front(); Q.pop(); for(i=0;i<4;i++){ intx=hd.x+dir[i][0],y=hd.y+dir[i][1]; if(x>=0&&x<=N-1&&y>=0&&y<=M-1&&map[x][y]!='#'){ point t; t.x=x; t.y=y; t.step=hd.step+1; t.time=hd.time+1; if(map[x][y]=='x'){ t.time++; } if(t.time mintime[x][y]=t.time; Q.push(t); } } } } return mintime[ax][ay]; int i,j; //freopen("C:\\Users\\acm\\Desktop\\001.in","r",stdin); while(scanf("%d%d",&N,&M)!=EOF){ memset(map,0,sizeof(map)); for(i=0;i scanf("%s",map[i]); } intsx,sy; pointstart; for(i=0;i for(j=0;j mintime[i][j]=INF; if(map[i][j]=='a'){ ax=i,ay=j; } else if(map[i][j]=='r'){ sx=i,sy=j; } } } start.x=sx,start.y=sy; start.step=0,start.time=0; mintime[sx][sy]=0; intmint=BFS(start); if(mint printf("%d\n",mint); } else{ printf("Poor ANGEL has tostay in the prison all his life.\n"); } } return 0;
代码:
#include
#include
#include
#include
#include
usingnamespace std;
const intMAXN=200;
const intINF=10000000;
typedefstruct points{
}point;
queueQ;
intN,M;
charmap[MAXN][MAXN];
intmintime[MAXN][MAXN];
intdir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
intax,ay;
intBFS(point s){
}
intmain(){
}
0 0
- HDOJ 1242 Rescue
- HDU 1242 Rescue
- hdoj acm 1008
- HDOJ 1984 Mispelling4
- HDOJ 1015 Safecracker
- HDOJ 2052 Picture
- HDOJ 4325 Flowers
- hdoj acm 1029
- Rightmost Digit hdoj 1061
- HDOJ 1005 Number Sequence
- HDOJ 1722 Cake
- HDOJ 1350 Robot Motion
- HDOJ 1181 变形课
- HDOJ 1013 Digital Roots
- HDOJ 2072 单词数
- HDOJ 2081 手机短号
- HDOJ 1846 Brave Game
- HDOJ 2568 前进
- KMP字符串模式匹配详解
- 字典树
- 转载用ST的RMQ算法
- POJ 2364 Balanced Lineup
- HDOJ 4278 Faulty Odometer
- HDOJ 1242 Rescue
- 【转载】C语言中scanf格式化输入函…
- POJ 2406 Power St…
- 快速幂取模运算
- HDOJ 1316 2^x mod n = 1
- HDOJ 1316 How Many Fibs?
- POJ 3261 Milk Patterns[后缀数组]
- POJ 1743 Musical Theme[后缀数组]
- 【郑轻oj】1851-KILL(三国杀,贪心)(好玩!)