原题连接: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. input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'

    今天学习python基础—分支与循环,接触到了if.在练习一个if语句的时候,出现了错误. 题目是: 根据分数划分成四个级别:优秀.良好.及格.不及格,分数是72: grade = 72if grad ...

  2. PHP 比较运算符 var_dump("a" == 0) 为 true

    这篇文章主要讲解一下 PHP 使用比较运算符容易出错的地方 $a == $b 等于 TRUE,如果类型转换后 $a 等于 $b.$a === $b 全等 TRUE,如果 $a 全等于 $b,并且它们的 ...

  3. 剑指offer-重建二叉树04

    题目描述 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字.例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7, ...

  4. 电信学院第一届新生程序设计竞赛题解及std

    首先非常感谢各位同学的参加,还有出题验题同学的辛勤付出 昨天想偷懒就是不想再把我C++11的style改没了,大家看不懂的可以百度一下哦,懒得再写gcc了,毕竟代码是通的 //代表的是行注释,所以那个 ...

  5. 二分查找树按照key值划分

    #include <iostream>#include <vector>#include <algorithm>#include <string>#in ...

  6. ocrosoft Contest1316 - 信奥编程之路~~~~~第三关问题 D: 手机话费

    http://acm.ocrosoft.com/problem.php?cid=1316&pid=3 题目描述 小明的手机每天消费1元,每消费K元就可以获赠1元,一开始小明有M元,问最多可以用 ...

  7. 华为手机怎么安装Google

    华为手机怎么安装google 新买了个华为荣耀九,结果安装Google Play提示gms core 步骤一 gms 安装器.应用市场已经下架了  地址:链接: 点击打开链接 密码: m63j 步骤二 ...

  8. intellij idea 2017 工具使用问题

    1.打开idea 打开maven项目报错:Unable to import maven project 2.在idea中Help->Show Log in Explorer->idea.l ...

  9. js文字效果

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  10. 2013年 ACMICPC 杭州赛区H题

    思路:树状数组统计.待验证,不知道是否对. #include<cstdio> #include<cstring> #include<cmath> #include& ...