最近会多做点巩固基础的题目

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#define rep(i,j,k) for(register int i=j;i<=k;i++)
#define rrep(i,j,k) for(register int i=j;i>=k;i--)
#define erep(i,u) for(register int i=head[u];~i;i=nxt[i])
#define iin(a) scanf("%d",&a)
#define lin(a) scanf("%lld",&a)
#define din(a) scanf("%lf",&a)
#define s0(a) scanf("%s",a)
#define s1(a) scanf("%s",a+1)
#define print(a) printf("%lld",(ll)a)
#define enter putchar('\n')
#define blank putchar(' ')
#define println(a) printf("%lld\n",(ll)a)
#define IOS ios::sync_with_stdio(0)
using namespace std;
const int maxn = 1e3+11;
const int oo = 0x3f3f3f3f;
const double eps = 1e-7;
typedef long long ll;
ll read(){
ll x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
bool dp[maxn][maxn];
char a[maxn],b[maxn],c[maxn];
int main(){
int T=read(),kase=0;
while(T--){
s1(a);s1(b);s1(c);
memset(dp,0,sizeof dp);
int la=strlen(a+1),lb=strlen(b+1),lc=strlen(c+1);
dp[0][1]=bool(b[1]==c[1]);
dp[1][0]=bool(a[1]==c[1]);
rep(i,2,la) dp[i][0]|=(dp[i-1][0]&&a[i]==c[i]);
rep(i,2,lb) dp[0][i]|=(dp[0][i-1]&&b[i]==c[i]);
rep(i,1,la) rep(j,1,lb){
dp[i][j]|=(dp[i-1][j]&&a[i]==c[i+j]);
dp[i][j]|=(dp[i][j-1]&&b[j]==c[i+j]);
}
if(dp[la][lb]) printf("Data set %d: yes\n",++kase);
else printf("Data set %d: no\n",++kase);
}
return 0;
}

ZOJ - 2401 水DP的更多相关文章

  1. CodeForces 706C Hard problem (水DP)

    题意:对于给定的n个字符串,可以花费a[i]  将其倒序,问是否可以将其排成从大到小的字典序,且花费最小是多少. 析:很明显的水DP,如果不是水DP,我也不会做.... 这个就要二维,d[2][max ...

  2. 水dp第二天(背包有关)

    水dp第二天(背包有关) 标签: dp poj_3624 题意:裸的01背包 注意:这种题要注意两个问题,一个是要看清楚数组要开的范围大小,然后考虑需要空间优化吗,还有事用int还是long long ...

  3. HDU 2084 数塔 (水DP)

    题意:.... 析:从下往上算即可,水DP. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #incl ...

  4. hdu 2571 命运(水DP)

    题意: M*N的grid,每个格上有一个整数. 小明从左上角(1,1)打算走到右下角(M,N). 每次可以向下走一格,或向右走一格,或向右走到当前所在列的倍数的列的位置上.即:若当前位置是(i,j), ...

  5. ZOJ 3626(树形DP+背包+边cost)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3626 题目大意:树中取点.每过一条边有一定cost,且最后要回 ...

  6. zoj 3822 Domination(dp)

    题目链接:zoj 3822 Domination 题目大意:给定一个N∗M的棋盘,每次任选一个位置放置一枚棋子,直到每行每列上都至少有一枚棋子,问放置棋子个数的期望. 解题思路:大白书上概率那一张有一 ...

  7. ZOJ - 1108 输出DP方案

    DP方程太水不解释 熟悉一下输出的套路 #include<iostream> #include<algorithm> #include<cstdio> #inclu ...

  8. HDU 4960 (水dp)

    Another OCD Patient Problem Description Xiaoji is an OCD (obsessive-compulsive disorder) patient. Th ...

  9. UVALive 6430 (水dp)

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

随机推荐

  1. CentOS 安装mongodb3.0 二进制包

    1.下载mongodb因为64位系统CentOS,所以下载64位的安装包: wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0 ...

  2. java方法学习记录

    ---恢复内容开始--- 方法重载:两个方法有相同的名字,但参数不同,就是方法重载,且不能仅仅依据修饰符或者返回类型的不同来重载方法. 命令行参数的使用 有时候你希望运行一个程序时候再传递给它消息.这 ...

  3. Math.max()

    返回两个指定的数中带有较大的值的那个数.

  4. LINUX 查看CUP温度

    在Linux下可以通过lm_sensors来查看CPU的温度(当然你的硬件首先要支持),要使用这个功能要有内核相关模块(比如I2C)的支持,下面说一下操作方法: 先看一下你的机器上是否安装了lm_se ...

  5. 如何获取.properties配置文件

    如何获取.properties配置文件 分析思路: 先使用流和文件关联,即读取文件 再读取文件内容,一行一行读取 字符分割“=”  键值对 然后把键值对放到集合中去 但是Properties类里面有方 ...

  6. html页面源代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. Linux下安装memcache PHP扩展

    [root@centos memcache-2.2.4]# wget http://pecl.php.net/get/memcache-2.2.4.tgz [root@centos memcache- ...

  8. (转)15个非常棒的jQuery无限滚动插件【瀑布流效果】

    原文地址:http://www.cnblogs.com/lyw0301/archive/2013/06/19/3145084.html 现在,最热门的网站分页趋势之一是jQuery的无限滚动(也即瀑布 ...

  9. ABP源码uml类图

    陆陆续续学习ABP框架有一段时间了,阳光铭睿的入门教程和HK Zhang的源码分析文章对我的学习帮助都很大.之所以会花这么大工夫去学习ABP.看ABP的源代码,一是因为本人对于DDD也非常有兴趣,AB ...

  10. 关于AJAX与JSON的杂记

    一.当网页需要有多个XMLHttpRequest对象时,可以使用Callback 函数,callback 函数是一种以参数形式传递给另一个函数的函数. <html> <head> ...