poj2251的代码又改了改~
来源:互联网 发布:cf一直出现网络异常 编辑:程序博客网 时间:2024/06/10 03:16
#include<iostream>using namespace std;#include<queue>#include<cstring>#include<string>char temp;bool vis[50][50][50];bool vist[50][50][50];const int dx[6] = {1,-1,0,0,0,0};const int dy[6] = {0,0,1,-1,0,0};const int dz[6] = {0,0,0,0,-1,1};struct node{ int x,y,z; int step;};node now;node S,T;int bfs(){ memset(vis,false,sizeof(vis)); queue<node>q; q.push(S); while(!q.empty()) { now = q.front(); q.pop(); for(int i=0; i<6; i++) { node New; New.x = now.x + dx[i]; New.y = now.y + dy[i]; New.z = now.z + dz[i]; New.step = now.step + 1; if(!vist[New.x][New.y][New.z] || vis[New.x][New.y][New.z]) continue; q.push(New); vis[New.x][New.y][New.z] = true; if(New.x == T.x && New.y == T.y && New.z == T.z) return New.step; } } return -1;}int main(){ int L, R, C; while(cin >> L >> R >> C && L) { memset(vist,false,sizeof(vist)); for(int i=1; i<=L; i++) { for(int j=1; j<=R; j++) { for(int k=1; k<=C; k++) { cin >> temp; if(temp == 'S') { vist[i][j][k] = true; S.x = i; S.y = j; S.z = k; S.step = 0; } if(temp == 'E') { vist[i][j][k] = true; T.x = i; T.y = j; T.z = k; } if(temp == '.') { vist[i][j][k] = true; } } } } int ans = bfs(); if (ans<0) cout <<"Trapped!" << endl; else cout << "Escaped in " <<ans << " minute(s)." << endl; } return 0;}
0 0
- poj2251的代码又改了改~
- 淘宝又改了又改了又改了
- 需求又改了
- 需求又改了
- 今天又改了CRACKME
- CSDN 界面又改了
- 呃 我们的项目又改Ext做ui了~
- 过滤html标签(网上找的,又改了改)
- 改改改,又不知道改了多少遍!!!!!!
- 改了几天,又回归到原来
- CSDN密码又被改了
- Carbide C++ 改uidesign会把代码也改了
- 今天又把昨天那个打星星的程序改了一下!
- play on words又是一道改了很久的题
- QQ的名字改了
- 之前收藏了一个动态循环队列的代码,不太好用,改了改,留着备用
- 四天时间改了一行代码
- 改代码低效率的原因
- Ubuntu系统用户名、密码、主机名管理
- 机器分配
- Linux SD卡驱动开发(一) —— SD 相关基础概念
- 想算法无头绪,咋办?
- 【LeetCode】41. First Missing Positive的解法及注释
- poj2251的代码又改了改~
- iOS的适配问题
- Java IO流基本操作
- 省赛一Ballons dfs
- 几个关键字
- codeforces 659E New Reform
- hdu Problem 1242 Rescue bfs + 优先队列
- 事务及并发控制(锁,死锁,恢复)
- 专题一总结 贪心算法