CF586D. Phillip and Trains
/*
CF586D. Phillip and Trains
http://codeforces.com/problemset/problem/586/D
搜索
*/
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
const int Nmax=;
char map[][Nmax];
int fail[][Nmax];
int n,k;
int t,ans; int dfs(int step,int pos)
{
if(step==n- && map[pos][step+]=='.')
{
ans=;
return ;
}
if(step>=n)
{
ans=;
return ;
}
if(ans)
return ;
if(fail[pos][step])
return ; if(map[pos][step]>='A' && map[pos][step]<='Z')
{
fail[pos][step]=;
return ;
}
for(int k=pos-;k<=pos+;k++)
{
if(k>= && k<= && map[pos][step+]=='.' &&map[k][step+]=='.' && !fail[k][step+] && !fail[k][step+] && !fail[k][step+])
{
if(map[k][step+]=='.' && map[k][step+]=='.')
{
if(dfs(step+,k))
{
ans=;
return ;
}
else
{
fail[k][step+]=;
}
} }
}
fail[pos][step]=;
return ;
} int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&k);
for(int i=;i<=;i++)
for(int j=;j<=n+;j++)
fail[i][j]=;
getchar();
gets(map[]+);
gets(map[]+);
gets(map[]+);
for(int i=;i<=;i++)
for(int j=n+;j<=n+;j++)
map[i][j]='.';
ans=;
int pos=,start;
for(int i=;i<=;i++)
if(map[i][]=='s')
pos=i; if(dfs(,pos))
printf("YES\n");
else
printf("NO\n");
}
return ;
}
CF586D. Phillip and Trains的更多相关文章
- Codeforces 586D. Phillip and Trains 搜索
D. Phillip and Trains time limit per test: 1 second memory limit per test :256 megabytes input: stan ...
- Codeforces Round #325 (Div. 2) D. Phillip and Trains BFS
D. Phillip and Trains Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/ ...
- Codeforces 586D Phillip and Trains(DP)
题目链接 Phillip and Trains 考虑相对位移. 每一轮人向右移动一格,再在竖直方向上移动0~1格,列车再向左移动两格. 这个过程相当于每一轮人向右移动一格,再在竖直方向上移动0~1格, ...
- (中等) CF 585B Phillip and Trains,BFS。
The mobile application store has a new game called "Subway Roller". The protagonist of the ...
- 【33.33%】【codeforces 586D】Phillip and Trains
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- CodeForces - 586D Phillip and Trains 搜索。vis 剪枝。
http://codeforces.com/problemset/problem/586/D 题意:有一个3*n(n<100)的隧道.一个人在最左边,要走到最右边,每次他先向右移动一格,再上下移 ...
- Codeforces Round #325 (Div. 2) Phillip and Trains dp
原题连接:http://codeforces.com/contest/586/problem/D 题意: 就大家都玩过地铁奔跑这个游戏(我没玩过),然后给你个当前的地铁的状况,让你判断人是否能够出去. ...
- CodeForces - 586D Phillip and Trains
这道题是一道搜索题 但是 如果没有读懂或者 或者拐过弯 就很麻烦 最多26个火车 那么每一个周期 (人走一次 车走一次) 就要更改地图 的状态 而且操作复杂 容易超时 出错 利用相对运动 计周期为 人 ...
- 【Mutual Training for Wannafly Union #1 】
A.Phillip and Trains CodeForces 586D 题意:过隧道,每次人可以先向前一格,然后向上或向下或不动,然后车都向左2格.问能否到达隧道终点. 题解:dp,一开始s所在列如 ...
随机推荐
- Systick 更新
之前写的systick_config(loadvalue) 根据系统时钟为72Mhz来写的,如果system clock不是72MHz怎么办? 重新写了一下,先获取,系统时钟频率. //参数为ms v ...
- word文档在线预览解决方案
花了一整天在网上翻关于 “word文档在线预览解决方案” 相关的资料,感觉实现难度比较大还是用PDF来解决好了.. 下面列一下比较好的参考资料吧 参考资料 前端实现在线预览pdf.word.xls.p ...
- Testng1
Testng 简介: Testng是一套开源测试框架,是从Junit继承而来,testng意为test next generation,主要有以下特性: annotations 注释,如 @test ...
- sql数据库中常用连接
很简单的知识点,今天有点搞不清楚左外连接,右外连接:详见以下: --表stu id name 1, Jack 2, Tom 3, Kity 4, nono --表exam id grade 1, 56 ...
- 【Codeforces827D/CF827D】Best Edge Weight(最小生成树性质+倍增/树链剖分+线段树)
题目 Codeforces827D 分析 倍增神题--(感谢T*C神犇给我讲qwq) 这道题需要考虑最小生成树的性质.首先随便求出一棵最小生成树,把树边和非树边分开处理. 首先,对于非树边\((u,v ...
- 参加2016华为codecraft编程精英挑战赛后感
2016年4月参加了华为的软件比赛. 关于比赛:给了一道图论的np-hard问题.刚开始完全不知道怎么入手,请教过师兄,自己也琢磨过,没有什么万全的解决方法.注意,这里说的是万全的办法.本科搞算法时候 ...
- BOM 标记
BOM 是 Byte Order Mark 的简称,即字节序标记.用于标记文本流: 表示文本流的字节顺序,是小端序(little-endian)还是大端序(big-endian); 表示文本流是 Un ...
- git——merge和rebase的区别
参考http://www.jianshu.com/p/129e721adc6e 我在公司里看到其他同事都使用git pull --rebase拉取远程代码,而我总是用git pull,也有同事和我说过 ...
- Android项目实战_手机安全卫士进程管理
###1.设备进程信息获取获取设备运行进程 ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVI ...
- http服务器与https服务器的区别
1.HTTPS服务器使用的是HTTPS协议,而HTTP使用的是HTTP协议. 2.HTTPS服务器需要向证书授权中心申请证书,一般免费证书很少,需要交费. 3.HTTP服务器与客户端传递的是明文数据, ...