原题连接:http://codeforces.com/contest/586/problem/D

题意:

就大家都玩过地铁奔跑这个游戏(我没玩过),然后给你个当前的地铁的状况,让你判断人是否能够出去。

题解:

就首先预处理一下每个点在哪些时刻会被车子占领,然后从右向左dp一下就好

代码:

#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#define MAX_N 123
using namespace std;
int n,k; string ma[]; bool d[][MAX_N][MAX_N];
int T;
bool dp[][MAX_N]; void print(){
for(int i=;i<;i++,cout<<endl)
for(int j=;j<n;j++)cout<<dp[i][j]<<" ";
cout<<"----"<<endl;
} int main(){
cin.sync_with_stdio(false);
cin>>T;
while(T--){
cin>>n>>k;
memset(dp,,sizeof(dp));
memset(d,,sizeof(d));
for(int i=;i<;i++)cin>>ma[i];
for(int i=;i<;i++)
for(int j=;j<n;j++)
if(ma[i][j]<='Z'&&ma[i][j]>='A')
for(int k=j,t=;k>=;k-=,t++)
d[i][k][t]=;
for(int i=;i<;i++)
dp[i][]=('s'==ma[i][]);
for(int j=;j<n-;j++){
for(int i=;i<;i++){
if(dp[i][j]){
if(d[i][j+][j])continue;
for(int k=;k<;k++)
if(d[k][j+][j]==&&d[k][j+][j+]==&&abs(k-i)<=)
dp[k][j+]=;
}
}
//print();
}
bool ans=;
for(int i=;i<;i++)ans|=dp[i][n-];
if(ans)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return ;
}

Codeforces Round #325 (Div. 2) Phillip and Trains dp的更多相关文章

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

  2. Codeforces Round #325 (Div. 2) D bfs

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

  3. Codeforces Round #325 (Div. 2)

    水 A - Alena's Schedule /************************************************ * Author :Running_Time * Cr ...

  4. Codeforces Round #174 (Div. 1) B. Cow Program(dp + 记忆化)

    题目链接:http://codeforces.com/contest/283/problem/B 思路: dp[now][flag]表示现在在位置now,flag表示是接下来要做的步骤,然后根据题意记 ...

  5. Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid

    F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  6. Codeforces Round #325 (Div. 2) C. Gennady the Dentist 暴力

    C. Gennady the Dentist Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586 ...

  7. Codeforces Round #325 (Div. 2) A. Alena's Schedule 水题

    A. Alena's Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/pr ...

  8. Codeforces Round #325 (Div. 2) B. Laurenty and Shop 前缀和

    B. Laurenty and Shop Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/p ...

  9. Codeforces Round #325 (Div. 2) Laurenty and Shop 模拟

    原题链接:http://codeforces.com/contest/586/problem/B 题意: 大概就是给你一个两行的路,让你寻找一个来回的最短路,并且不能走重复的路. 题解: 就枚举上下选 ...

随机推荐

  1. 转:Redis设置认证密码 Redis使用认证密码登录 在Redis集群中使用认证密码

    Redis默认配置是不需要密码认证的,也就是说只要连接的Redis服务器的host和port正确,就可以连接使用.这在安全性上会有一定的问题,所以需要启用Redis的认证密码,增加Redis服务器的安 ...

  2. Python处理Sqlite3数据库

    sqlite3比较小众 本章主要通过Python Code表述如何增.查.改.删 sqlite3 DB 一.直接上代码 #!/usr/bin/env python # -*- coding: utf- ...

  3. NGUI-UIProgressBar,UIScrollBar,UISlider

    UIProgressBar是UIScrollBar和UISlider的基类 1.先来看下UIProgressBar(进度条)的使用 层次: progressBar的Inspector视图: 而fore ...

  4. drf解决跨域问题 使用 django-corse-headers扩展

    跨域CORS 使用django-corse-headers扩展 安装 pip install django-cors-headers 添加应用 INSTALLED_APPS = ( ... 'cors ...

  5. 关于 vee-validate直接引用的方法

    转载于:https://blog.csdn.net/hy111/article/details/79046500?%3E 由于当前项目使用的是基于jQuery的前端结构,尝试在新增需求中使用VUE2, ...

  6. HDU 4262 Juggler 树状数组

    将每个球按输入顺序编号,建立 它第几个被扔掉->编号 的映射关系. 记录当前在手里的球的编号,按扔掉的顺序查找这个球的编号,看看这个球是逆时针转到手里更近还是顺时针转到手里更近,即当前扔掉球的编 ...

  7. 【现代程序设计】homework-01

    HOMEWORK-01 1) 建立 GitHub 账户, 把课上做的 “最大子数组之和” 程序签入 已完成. 2) 在 cnblogs.com 建立自己的博客. 写博客介绍自己的 GitHub 账户. ...

  8. JSP/Servlet Web 学习笔记 DayOne

    JSP概述 1)JSP是一种动态网页技术标准,它是在传统的页面HTML文件中插入Java程序段和JSP标记(tag),从而形成JSP文件(*.jsp),也称JSP页面. 2)JSP容器是一个支持JSP ...

  9. jquery select chosen 动态绑定值

    $("#ddlMstData").find("option[value=" + data.MstKey + "]").attr(" ...

  10. LeetCode -- Sum Root to Leaf NNumbers

    Related Links: Path Sum: http://www.cnblogs.com/little-YTMM/p/4529982.html Path Sum II: http://www.c ...