第二次遇到双塔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. ESXi6.7安装流程和bug处理

    ·前言 ·准备工作 ·安装 ·Initializing IOV卡住 ·缺少网卡驱动 ·安装ESXi6.7 ·Multiboot could not setup the video subsystem ...

  2. RabbitMQ入门_15_访问控制

    参考资料:https://www.rabbitmq.com/access-control.html A. 核心概念 Virtual Host:虚拟主机为 RabbitMQ 中的资源提供了逻辑分组与隔离 ...

  3. [html]点击button后画面被刷新原因:未设置type="button"

    一.问题原因解析: 在form表单里的button, type 属性未设置的情况下,Internet Explorer 的默认类型是 "button",而其他浏览器中(包括 W3C ...

  4. Unity另外一套简单日志控制系统

    using UnityEngine; public class LogPrintf { static LogLevel logLevel = LogLevel.LOG_LEVEL_ERROR; pub ...

  5. WPF操作RichTextBox

    http://www.cnblogs.com/wzwyc/p/6291895.html

  6. 3-19(晚) require_relative 和 require. === operator的解释。

    kernel#require_relative Ruby tries to load the library named string relative to the requiring file's ...

  7. python-day63--前端

    一. 响应式介绍 - 响应式布局是什么? 同一个网页在不同的终端上呈现不同的布局等 - 响应式怎么实现的? 1. CSS3 media query 媒体查询 2. JS去控制网页的布局和样式等 - 缺 ...

  8. hdu 1226 bfs+余数判重+大数取余

    题目: 超级密码 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  9. 二分求LIS并打印结果

    1275: God's ladder [DP] 时间限制: 1 Sec 内存限制: 128 MB  Special Judge 题目描述 天明来到神之宫殿,在他眼前出现了若干个石柱,每个石柱上有1枚金 ...

  10. NOJ-1581 筷子 (线性DP)

    题目大意:有n支筷子,已知长度,定义一双筷子的质量等于长度的平方差,问能否分成k双?若能,输出所有筷子的最小质量和. 题目分析:先将筷子按长度从小到大排序,定义状态dp(i,j)表示将前 i 支筷子分 ...