/*
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的更多相关文章

  1. Codeforces 586D. Phillip and Trains 搜索

    D. Phillip and Trains time limit per test: 1 second memory limit per test :256 megabytes input: stan ...

  2. 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/ ...

  3. Codeforces 586D Phillip and Trains(DP)

    题目链接 Phillip and Trains 考虑相对位移. 每一轮人向右移动一格,再在竖直方向上移动0~1格,列车再向左移动两格. 这个过程相当于每一轮人向右移动一格,再在竖直方向上移动0~1格, ...

  4. (中等) CF 585B Phillip and Trains,BFS。

    The mobile application store has a new game called "Subway Roller". The protagonist of the ...

  5. 【33.33%】【codeforces 586D】Phillip and Trains

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. CodeForces - 586D Phillip and Trains 搜索。vis 剪枝。

    http://codeforces.com/problemset/problem/586/D 题意:有一个3*n(n<100)的隧道.一个人在最左边,要走到最右边,每次他先向右移动一格,再上下移 ...

  7. Codeforces Round #325 (Div. 2) Phillip and Trains dp

    原题连接:http://codeforces.com/contest/586/problem/D 题意: 就大家都玩过地铁奔跑这个游戏(我没玩过),然后给你个当前的地铁的状况,让你判断人是否能够出去. ...

  8. CodeForces - 586D Phillip and Trains

    这道题是一道搜索题 但是 如果没有读懂或者 或者拐过弯 就很麻烦 最多26个火车 那么每一个周期 (人走一次 车走一次) 就要更改地图 的状态 而且操作复杂 容易超时 出错 利用相对运动 计周期为 人 ...

  9. 【Mutual Training for Wannafly Union #1 】

    A.Phillip and Trains CodeForces 586D 题意:过隧道,每次人可以先向前一格,然后向上或向下或不动,然后车都向左2格.问能否到达隧道终点. 题解:dp,一开始s所在列如 ...

随机推荐

  1. B4197 [Noi2015]寿司晚宴 状压dp

    这个题一开始想到了唯一分解定理,然后状压.但是显然数组开不下,后来想到每个数(n<500)大于19的素因子只可能有一个,所以直接单独存就行了. 然后正常状压dp就很好搞了. 题干: Descri ...

  2. nginx初相识

    在本机上下载了一个nginx,版本为1.14.0. 安装: 对于安装比较简单,下载后解压到指定目录,目录结构如下 启动: 最简单的直接双击nginx.exe,有黑窗一闪而过,不要怀疑,看一下logs的 ...

  3. hadoop一主一从部署(1)

    一.安装前说明 主机IP:192.168.132.128 从机IP:192.168.132.129 1. 所有的安装包我放在了/root/这个目录下,你要根据自己情况去修改,这点必须注意 2. 采用的 ...

  4. ZOJ3714JavaBeans

    #!/usr/bin/env python # encoding: utf-8 t = int(raw_input()) for i in range(t): n,k = [int(x) for x ...

  5. JavaScript--编程练习1

    使用JS完成一个简单的计算器功能.实现2个输入框中输入整数后,点击第三个输入框能给出2个整数的加减乘除. 提示:获取元素的值设置和获取方法为:例:赋值:document.getElementById( ...

  6. UNIX环境高级编程--2

    UNIX标准及实现 ISO C: 国际标准化组织(International Organization for standardization , ISO)ISO C标准的意图是提供C程序的可移植性, ...

  7. 大话设计模式--DI(依赖注入)

    1.背景 想象一个场景:有个功能通过某个参数决定了路由到不同的方法上或者几个方法模块可以自由搭配,咋办?一般人会对每个方法写一个helper(比如SendMessageForEmail.SendMes ...

  8. [ POI 2011 ] Dynamite

    \(\\\) \(Description\) 一棵\(N\)个节点的树,树上有\(M\)个节点是关键点,选出\(K\)个特殊点,使得所有关键点到特殊点的距离中最大的最小,输出最大值最小为多少. \(N ...

  9. JS高级——面向对象方式解决歌曲管理问题

    需要注意的问题: 1.其他模块若是使用构造函数MP3创建对象,唯一不同的就是他们传入的音乐库是不一样的,所以构造函数中存在一个songList属性,其他一样的就被添加到了构造函数的原型对象之中 2.原 ...

  10. Ajax——php基础知识(三)

    上传文件 1.get是传不了文件的,只能用post 2.enctype需要重新设置,默认是application/x-www-form-urlencoded,会在发送到服务器之前,所有字符都会进行编码 ...