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所在列如 ...
随机推荐
- 在Struts2中ognl.MethodFailedExceptiond异常的解决办法
问题描述: 在 Struts2 里面,当页面向服务器提交参数时报ognl.MethodFailedException:和java.lang.NoSuchMethodException:异常 异常信息 ...
- 利用Spinnaker创建持续交付流水线
在Pivotal Container Service (PKS)上部署软件的方法多种多样,本文重点介绍如何使用Spinnaker在PKS(或任何Kubernetes群集)上进行持续交付. Pivota ...
- codevs1085数字游戏(环形DP+划分DP )
1085 数字游戏 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 丁丁最近沉迷于一个数字游戏之中.这个游戏看似简单, ...
- [Swift通天遁地]四、网络和线程-(9)上传图片并实时显示上传进度
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- Canvas和SVG的基础知识,以及两者的区别(小白)
首先我们来说一下Canvas是什么,它有什么作用以及它的知识点. Canvas是<HTML5>的新标签,它通常用于通过脚本(也就是JavaScript)来绘制图像.但是它本身并没有绘制能力 ...
- SQL之T-sql 语句操作数据库
用SQL语句操作数据库 在上一次的话题中我们谈到了怎么使用数据库,说到了数据库的基本用法. 不过只是仅限于一些简单的操作,so 如果你不想被人说--"你们只是动动鼠标操作就可以了! 没什么技 ...
- P2871 [USACO07DEC]手链Charm Bracelet
题目描述 Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like t ...
- Maven 学习(1)
Maven是什么,以及为什么要使用Maven?Maven这个词可以翻译为“知识的积累”,也可以翻译为“专 家”或“内行”.(构建 = 编写源代码+编译源代码+单元测试+生成文档+打包War+部署)Ma ...
- win32窗口映射(部分)
先理解一下“窗口”与“视区”的概念.“窗口”是逻辑坐标下的矩形区域,“视区”是设备坐标系下的区域.根据“窗口”和“视区”的大小可以确定x方向和y方向的比例因子. 例子如下: VOID OnPaint( ...
- 一个有趣的 ”Validation of viewstate MAC failed” 错误的发现和解决
在ASP.NET里面,View State使用较为广泛.它作为一个隐藏字段,可以帮助服务端”记住“客户端的改变,这样客户端 收到服务器对PostBack的响应后,仍然可以展现在PostBack之前设定 ...