第二次遇到双塔DP,再写一下。
(flag是为了避免memset多次导致的时间浪费)

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
using namespace std;
char x[],y[],z[];
int map[][],L,Lx;//410=210+x
bool _find(int flag)
{
for(int i=;i<=L;i++)
{
for(int j=;j<=min(Lx,i);j++)
if(map[i-][j]==flag)
{
if(j+<=min(Lx,i)&&x[j+]==z[i]) map[i][j+]=flag;
if(y[i-j]==z[i]) map[i][j]=flag;
}
}
if(map[L][Lx]==flag) return true;
return false;
}
int main()
{
int T;
cin>>T;
for(int i=;i<=T;i++)
{
map[][]=i;
scanf("%s",x+);
scanf("%s",y+);
scanf("%s",z+);
Lx=strlen(x+);
L=strlen(z+);
if(_find(i)) printf("Data set %d: yes\n",i);
else printf("Data set %d: no\n",i);
}
return ;
}


ZOJ2401 Zipper 双塔式 DP(双塔DP)的更多相关文章

  1. ZOJ2401 Zipper 双塔式 DP

    遇到双塔DP,写一下. flag是为了避免memset多次导致的时间浪费. #include<cstdio> #include<cstdlib> #include<ios ...

  2. VIJOS P1037搭建双塔[DP]

    描述 2001年9月11日,一场突发的灾难将纽约世界贸易中心大厦夷为平地,Mr. F曾亲眼目睹了这次灾难.为了纪念“9?11”事件,Mr. F决定自己用水晶来搭建一座双塔. Mr. F有N块水晶,每块 ...

  3. HDU 3578 Greedy Tino(双塔DP)

    Greedy Tino Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  4. POJ 2609 Ferry Loading(双塔DP)

    Ferry Loading Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1807   Accepted: 509   Sp ...

  5. ZOJ 3331 Process the Tasks(双塔DP)

    Process the Tasks Time Limit: 1 Second      Memory Limit: 32768 KB There are two machines A and B. T ...

  6. ZOJ 2059 The Twin Towers(双塔DP)

    The Twin Towers Time Limit: 2 Seconds      Memory Limit: 65536 KB Twin towers we see you standing ta ...

  7. POJ 1015 Jury Compromise(双塔dp)

    Jury Compromise Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 33737   Accepted: 9109 ...

  8. DP套DP HDOJ 4899 Hero meet devil(国王的子民的DNA)

    题目链接 题意: 给n长度的S串,对于0<=i<=|S|,有多少个长度为m的T串,使得LCS(S,T) = i. 思路: 理解的不是很透彻,先占个坑. #include <bits/ ...

  9. LightOJ1044 Palindrome Partitioning(区间DP+线性DP)

    问题问的是最少可以把一个字符串分成几段,使每段都是回文串. 一开始想直接区间DP,dp[i][j]表示子串[i,j]的答案,不过字符串长度1000,100W个状态,一个状态从多个状态转移来的,转移的时 ...

随机推荐

  1. Qt5_qtconfig

    1.http://tieba.baidu.com/p/3225596765 QtConfig was removed in Qt5. If you want to force Qt5 to use a ...

  2. 《WAP团队项目软件设计方案》

    WAP团队项目软件设计方案 一.根据OOD详细设计工作要点,修改完善团队项目系统设计说明书和详细设计说明文档的GitHub地址:https://github.com/LVowe999/-7.git 在 ...

  3. ASCII 对照表

    ASCII(American Standard Code for Information Interchange,美国信息互换标准代码,ASCⅡ)是基于拉丁字母的一套电脑编码系统.它主要用于显示现代英 ...

  4. Confluence 6 使用 LDAP 授权连接一个内部目录 - 用户 Schema 设置

    请注意:这部分仅在拷贝用户登录(Copy User on Login)功能被启用后可见. 其他用户 DN(Additional User DN) 这个值被用在进行用户查找和载入的时候来针对 base ...

  5. 第二类斯特林数(转自http://www.cnblogs.com/gzy-cjoier/p/8426987.html )

    转自http://www.cnblogs.com/gzy-cjoier/p/8426987.html 侵删

  6. layui的富文本编辑器怎么赋值

    除了上面讲的方法外,还可以使用layedit自带的方法赋值/*** 设置编辑器内容* @param {[type]} index 编辑器索引* @param {[type]} content 要设置的 ...

  7. CentOS 7 Install Redis

    1. yum install epel-release 2. yum install –y redis 3. start : systemctl start redis.service 4. stat ...

  8. ubuntu64位库

    安装 12.04ubuntu32位库:sudo apt-get install ia32-libs

  9. keras-anomaly-detection 代码分析——本质上就是SAE、LSTM时间序列预测

    keras-anomaly-detection Anomaly detection implemented in Keras The source codes of the recurrent, co ...

  10. tensoflow学习入门一

    对于如何创建图并开启session,参考如下 # -- encoding:utf-8 -- import tensorflow as tf # 定义常量矩阵a和矩阵b a=tf.constant([[ ...