原题连接: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. Linux(Ubuntu 命令大全)

    Ubuntu 一. Ubuntu简介 Ubuntu(乌班图)是一个基于Debian的以桌面应用为主的Linux操作系统,据说其名称来自非洲南部祖鲁语或科萨语的“ubuntu”一词,意思是“人性”.“我 ...

  2. MIFARE Classic S50技术详解

    Mifare Classic 简介 MIFARE Classic是恩智浦半导体开发的可用于非接触式智能卡,符合ISO/IEC 14443 A类标准.用于公共交通票证等应用,还可用于各类其他应用有S20 ...

  3. ubuntu系统更换源

    一:问题概述 ubuntu,我们在使用apt新装软件的时候,会使用官方的网站去下载软件,但是会因为国内的转接点太多,而导致下载的速度非常慢 ,我们可以通过换成一些中间的节点来进行下载,比如阿里源,中科 ...

  4. [洛谷P4320]道路相遇

    题目大意:基本同上一题[bzoj5329][Sdoi2018]战略游戏,只是每个点集内只有两个点,且只有一组询问而已.(双倍经验?我反正就直接改了一下代码就交了) 题解:同上一题(链接见“题目大意”) ...

  5. 2017 多校5 Rikka with String

    2017 多校5 Rikka with String(ac自动机+dp) 题意: Yuta has \(n\) \(01\) strings \(s_i\), and he wants to know ...

  6. BZOJ5300 [Cqoi2018]九连环 【dp + 高精】

    题目链接 BZOJ5300 题解 这题真的是很丧病,,卡高精卡到哭 我们设\(f[i]\)表示卸掉前\(i\)个环需要的步数 那么 \[f[i] = 2*f[i - 2] + f[i - 1] + 1 ...

  7. 威士忌(whiskey)

    威士忌(whiskey) 题目描述 Alan 喝了假威士忌,想问你一个问题: nvliu66 推荐大家读三本书<百年孤独>.<城市发展史>.<美国大城市的生与死>, ...

  8. ajax获取数据的处理和实例

    HTML: <!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" cont ...

  9. 转:Intent与PendingIntent

    intent英文意思是意图,pending表示即将发生或来临的事情. PendingIntent这个类用于处理即将发生的事情.比如在通知Notification中用于跳转页面,但不是马上跳转. Int ...

  10. 2018超详细sublime text3+python3.x安装配置教程(附常用插件安装教程)

    导读 本文是关于2018年7月最新版sublime text3+pythin3.x下载及安装配置教程,sublime text3版本为3176,python版本为3.7,安装环境是基于windows1 ...