原题连接: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. 基于Python的selenuim自动化测试尝试

    工作这么多年了,终于狠下心好好开始学学自动化测试相关知识,揭开这层神秘的面纱. 困难重重,障碍很多,但好在每天都多少有点小收获. 很感谢一个QQ好友推荐的虫师,也非常感谢在这个契机读到了虫师编著的&l ...

  2. tomcat运行solr

    https://blog.csdn.net/u010346953/article/details/67640036

  3. sources-x.list

    deb http://debian.ustc.edu.cn/ubuntu/ xenial main multiverse restricted universe deb http://debian.u ...

  4. 微信公众号开发java框架:wx4j(入门篇)

    导航 入门 http://www.cnblogs.com/2333/p/6617819.html WxServlet介绍 MaterialUtils 素材工具类使用说明 http://www.cnbl ...

  5. springmvc maven搭建一

    一.标题:使用maven搭建一个简单的web工程 二.涉及工具:Eclipse.maven.tomcat8.0.jdk1.8 三.操作: 完善项目:增加src/main/java,src/test/r ...

  6. 关于usr/bin/ld: cannot find -lxxx问题总结(Qt编译错误cannot find -lGL)

    决定终结这个问题!(网上要想找到完整的解答实在太难了) http://blog.sciencenet.cn/blog-676535-541444.html 前两天手贱,把虚拟机玩崩溃了,只好重装虚拟机 ...

  7. intellij idea导入不了java.util.Date解决办法

    可以在Settings -> Editor -> General -> Auto Import,将Exclude中的java.util.Date删除.

  8. 【bzoj4898】[Apio2017]商旅 Floyd+分数规划+Spfa

    题目描述 有n个点.m条边.和k种商品.第$i$个点可以以$B_{ij}$的价格买入商品$j$,并以$S_{ij}$的价格卖出.任何时候只能持有一个商品.求一个环,使得初始不携带商品时以某种交易方式走 ...

  9. NOIP2017赛前模拟11月2日总结

    分数爆炸的一天··但也学了很多 题目1:活动安排 给定n个活动的开始时间与结束时间··只有一个场地··要求保留尽量多的活动且时间不冲突···场地数n<=100000 考点:贪心 直接将结束时间按 ...

  10. Educational Codeforces Round 42 (Rated for Div. 2) B

    B. Students in Railway Carriage time limit per test 2 seconds memory limit per test 256 megabytes in ...