简单搜索题(D. Phillip and Trains)
来源:互联网 发布:淘宝领券链接 编辑:程序博客网 时间:2024/05/18 09:27
题目链接:点击打开链接
代码:
#include<stdio.h>#include<string.h>#include<algorithm>#include<queue>using namespace std;char q[5][200];int vis[5][200];int q1,q2;int biaoji;struct qq{ int x,y;} w,w1;queue<qq>w2;void bfs(int x,int y){ w.x=x; w.y=y; vis[w.x][w.y]=1; while(!w2.empty()) { w2.pop(); } w2.push(w); while(!w2.empty()) { w=w2.front(); w2.pop(); if(q[w.x][w.y+1]!='.') continue; if(w.y>=q1-1) { biaoji=1; return ; }//printf("") for(int i=0; i<3; i++) { int flag=0; if(abs(w.x-i)>1) continue; for(int j=1; j<4; j++) { if(q[i][w.y+j]!='.') { flag=1; break; } } if(flag==0&&vis[i][w.y+3]==0) { w1.x=i; w1.y=w.y+3; vis[w1.x][w1.y]=1; w2.push(w1); } } }}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d%d",&q1,&q2); memset(vis,0,sizeof(vis));// getchar(); int x,y; for(int i=0; i<3; i++) { scanf("%s",q[i]); for(int j=0; j<q1; j++) { if(q[i][j]=='s') { x=i,y=j; } } } for(int i=0; i<4; i++) for(int j=0; j<=5; j++) { q[i][q1+j]='.'; } biaoji=0; bfs(x,y); if(biaoji==1) printf("YES\n"); else printf("NO\n"); }}
深搜广搜都是可以的
0 0
- 简单搜索题(D. Phillip and Trains)
- CodeForces 586D Phillip and Trains (基础搜索 -- DFS)
- CodeForces 586D Phillip and Trains(搜索)
- Codeforces 586D Phillip and Trains【思维+Bfs】好题~!
- Codeforces #325 D. Phillip and Trains (bfs)
- Codeforces #325 Div2 D Phillip and Trains(模拟)
- CodeForces #325 D. Phillip and Trains
- 【33.33%】【codeforces 586D】Phillip and Trains
- Codeforces 586D Phillip and Trains
- Codeforces 586D Phillip and Trains
- Codeforces 586D Phillip and Trains 题解
- Codeforces Round #325 (Div. 2) D. Phillip and Trains (BFS)
- 【Codeforces Round #325 (Div. 2)】D. Phillip and Trains
- Codeforces Round #325 (Div. 2) D. Phillip and Trains
- CF Round #325 Div2 D. Phillip and Trains
- Codeforces Round #325 (Div. 2)-D. Phillip and Trains
- Codeforces586D. Phillip and Trains(DFS)
- CF 585B Phillip and Trains(预处理+BFS)
- MySql 时间比较:DATEDIFF函数与大于小于号
- OPENCV的2-10备注
- 安装selenium RC
- android studio编译运行各种踩坑解决方案
- 图片服务器架构
- 简单搜索题(D. Phillip and Trains)
- 一步集成侧滑(删除)菜单
- 《Refactoring》,Substitute Algorithm(替换算法)
- 主元素
- 清除WKWebView cookies
- Redis各种数据结构内存占用测试
- App开发:购物车
- Android Studio 常用快捷键
- linux USB驱动层次