hdu 1240 Asteroids!
来源:互联网 发布:java 代码覆盖率 编辑:程序博客网 时间:2024/05/23 14:35
点击打开链接
因为没令str[d][e][f]='O',导致wrong了无数次。。。而且郁闷了好几天。。
#include"stdio.h"#include"string.h"#include"queue"#include"ctype.h"using namespace std;int map[15][15][15];int flag,a,b,c,d,e,f,n;char str[15][15][15];int dir[6][3]={{1,0,0},{-1,0,0},{0,1,0},{0,1,0},{0,0,1},{0,0,-1}};struct node{ int x,y,z,step;};int judge(int x,int y,int z){ if(x>=0&&x<n&&y>=0&&y<n&&z>=0&&z<n &&map[x][y][z]==0&&str[x][y][z]=='O') return 1; return 0;}void bfs(){ int i,x,y,z; queue<node>q; node cur,next; memset(map,0,sizeof(map)); cur.x=a; cur.y=b; cur.z=c; cur.step=0; q.push(cur); map[a][b][c]=1; if(a==d&&b==e&&c==f) { printf("%d 0\n",n); return ; } while(!q.empty()) { cur=q.front(); q.pop(); for(i=0;i<6;i++) { next.x=x=cur.x+dir[i][0]; next.y=y=cur.y+dir[i][1]; next.z=z=cur.z+dir[i][2]; if(judge(x,y,z)) { map[x][y][z]=1; next.step=cur.step+1; if(x==d&&y==e&&z==f) { printf("%d %d\n",n,next.step); return ; } q.push(next); } } } printf("NO ROUTE\n");}int main(){ int i,j; char s[15],t[15]; while(scanf("%s %d",s,&n)==2) { for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%s",str[i][j]); scanf("%d%d%d",&a,&b,&c); scanf("%d%d%d",&d,&e,&f);str[d][e][f]='O';//这个千万不忘啊!! bfs(); scanf("%s",t); } return 0;}
- hdu 1240 Asteroids!
- HDU-1240-Asteroids!
- hdu 1240 Asteroids!
- hdu 1240 Asteroids!
- Hdu 1240 Asteroids!
- hdu 1240 Asteroids!
- hdu 1240 Asteroids!
- HDU 1240 Asteroids!
- hdu 1240 Asteroids BFS
- HDU 1240 Asteroids!
- hdu 1240 Asteroids!
- hdu-1240-Asteroids!
- HDU 1240 Asteroids!
- hdu 1240 Asteroids!bfs
- Asteroids! HDU 1240
- HDU 1240 Asteroids!(BFS)
- hdu 1240 Asteroids!(BFS)
- HDU 1240 Asteroids!
- 2012 Esri全球用户大会 Q&A之:移动GIS的发展
- 都是微信惹的祸
- IOS 程序禁止被调试
- Least Common Multiple&&http://acm.hdu.edu.cn/showproblem.php?pid=1019
- 混了大学,要继续找专业方向的工作吗?
- hdu 1240 Asteroids!
- spring cxf webservice
- B/S架构中的数据推送技术
- poj 3751 时间日期格式转换
- 基于SAML的单点登录介绍
- 一种巧妙的内存池算法(HeapBlock)
- 指向const对象的指针和const指针
- Android环境 驱动测试程序
- Shudepb and Pbkiller, PB DeCompiler