/*
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. geronimo

    时间限制 1s 空间限制 512MB 3.1 题目描述 "Geronimo∼" 时间还很多,让我们慢慢来. 不如听首开心的歌再看题?-- 算了,直接看题吧. 给定一个整数 n,以及 ...

  2. JZOJ 1667 ( bzoj 1801 ) [ AHOI 2009 ] 中国象棋 —— DP

    题目:https://jzoj.net/senior/#main/show/1667 首先,一行.一列最多只有 2 个炮: 所以记录一下之前有多少行有 0/1/2 个炮,转移即可: 注意取模!小心在某 ...

  3. PCB MS SQL SERVER 字段含小写字母更新为大写字母

    今天在预审完成时报如下错误,此错误原因是由于SQL Server数据字段存在小写,而Oracle数据库需大写导致的, 怎么解决这个问题了,非常简单 .这里将SQL贴出来 . 1.将生产型号中含有小写字 ...

  4. eclipse ------validation功能

    今天来讲讲eclipse 的validation功能,该功能用于检测代码存在的“潜在”问题,比如:JSP文件的语法错误,XML中的schema错误等,这么好的功能还有什么可讲的呢,我今天要讲的是val ...

  5. 互斥的数(hash)

    1553 互斥的数  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold     题目描述 Description 有这样的一个集合,集合中的元素个数由给定的N决定, ...

  6. 【洛谷3546_BZOJ2803】[POI2012]PRE-Prefixuffix(String Hash)

    Problem: 洛谷3546 Analysis: I gave up and saw other's solution when I had nearly thought of the method ...

  7. 涨知识-VI 基于TCP/UDP的应用层协议

    基于TCP/UDP的应用层协议: 基于TCP: Telnet(Teletype over the Network, 网络电传),通过一个终端(terminal)登陆到网络 FTP(File Trans ...

  8. iOS device is locked/unlocked (判断手机屏幕是否锁屏)

    #import <notify.h> -(void)checkDeviceLockScreenState { int notify_token; notify_register_dispa ...

  9. git——merge和rebase的区别

    参考http://www.jianshu.com/p/129e721adc6e 我在公司里看到其他同事都使用git pull --rebase拉取远程代码,而我总是用git pull,也有同事和我说过 ...

  10. 学习笔记-java IO流总结 转载

    1.什么是IO Java中I/O操作主要是指使用Java进行输入,输出操作. Java所有的I/O机制都是基于数据流进行输入输出,这些数据流表示了字符或者字节数据的流动序列.Java的I/O流提供了读 ...