HDU 2102 A计划
来源:互联网 发布:java script没有提示 编辑:程序博客网 时间:2024/05/18 14:26
水bfs。 只需要判断一下 #之后还是*或#都是死路。
只有两层。
#include<cstdio>#include<cstring>#include<string>#include<queue>#include<algorithm>#include<map>#include<stack>#include<iostream>#include<list>#include<set>#include<vector>#include<cmath>#define INF 0x7fffffff#define eps 1e-8#define LL long long#define PI 3.141592654#define CLR(a,b) memset(a,b,sizeof(a))#define FOR(i,a,n) for(int i= a;i< n ;i++)#define FOR0(i,a,b) for(int i=a;i>=b;i--)#define pb push_back#define mp make_pair#define ft first#define sd second#define acfun std::ios::sync_with_stdio(false)#define SIZE 10+1using namespace std;struct lx{ int x,y,z,t; void init(int xx,int yy,int zz,int tt) { x=xx,y=yy,z=zz,t=tt; }}thend,start;char g[2][SIZE][SIZE];int n,m;int xx[]={0,0,-1,1};int yy[]={-1,1,0,0};void bfs(){ bool vis[2][SIZE][SIZE]; CLR(vis,0); queue<lx>q; q.push(start); vis[0][0][0]=1; while(!q.empty()) { lx tmp=q.front(); q.pop(); //printf("%d %d %d t=%d\n",tmp.x,tmp.y,tmp.z,tmp.t); //system("pause"); if(tmp.t>thend.t)continue; if(tmp.x==thend.x&&tmp.y==thend.y&&tmp.z==thend.z&&tmp.t<=thend.t) { puts("YES"); return; } FOR(k,0,4) { int x=tmp.x+xx[k]; int y=tmp.y+yy[k]; int z=tmp.z; lx now; if(x<0||y<0||x>=n||y>=m||g[z][x][y]=='*'||vis[z][x][y])continue; vis[z][x][y]=1; if(g[z][x][y]=='#') { z^=1; if(g[z][x][y]=='*'||g[z][x][y]=='#')continue; } now.init(x,y,z,tmp.t+1); q.push(now); } } puts("NO");}int main(){ int t; scanf("%d",&t); while(t--) { int tt; scanf("%d%d%d",&n,&m,&tt); FOR(k,0,2) FOR(i,0,n) { char str[SIZE]; scanf("%s",str); FOR(j,0,m) { g[k][i][j]=str[j]; if(str[j]=='P') thend.init(i,j,k,tt); } } start.init(0,0,0,0); bfs(); }}
0 0
- hdu 2102 A计划
- HDU-2102-A计划
- HDU 2102 A计划
- HDU 2102 A计划
- HDU 2102 A计划
- hdu 2102 A计划
- hdu 2102 A计划
- hdu 2102 A计划
- hdu 2102 A计划
- hdu(2102) A计划
- hdu 2102 A计划
- HDU 2102 A计划
- HDU 2102 A计划
- HDU 2102 A计划
- HDU 2102A计划
- HDU 2102 A计划
- hdu 2102 A计划
- HDU 2102 A计划
- 走近云计算
- redis lua local 作用域
- 使用Spring @Async异步执行方法的笔记
- ofbiz最新版13.07.01环境搭建、安装(linux环境下)
- Xcode5和6共存时,如何发布应用到商店
- HDU 2102 A计划
- 封装网络请求库,统一处理通用异常 (基于volley网络请求库)
- hdu1005Number Sequence
- 图像锐化(增强)和边缘检测
- xml 特殊字符的表示
- facebook SDK授权
- 【bzoj 1600】: [Usaco2008 Oct]建造栅栏
- VC项目配置基础
- 误 drop table 的恢复