POJ 2192 Zipper
来源:互联网 发布:游戏优化怎么做 编辑:程序博客网 时间:2024/06/12 18:31
题目地址:http://poj.org/problem?id=2192
思路:因为只能依次取,所以c[i+j]这个字符肯定是由a[i]或者b[j]构成的
AC代码:
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <map>#include <cstring>#include <climits>#include <cmath>#include <cctype>const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;char a[210],b[210],c[420];int dp[210][210];int main(){ int cas = 1,t; scanf("%d",&t); while(t--) { memset(dp,0,sizeof(dp)); scanf("%s%s%s",a+1,b+1,c+1); int len1 = strlen(a+1); int len2 = strlen(b+1); dp[0][0] = 1; for(int i=0; i<=len1; i++) { for(int j=0; j<=len2; j++) { if(i >= 1 && c[i+j] == a[i] && dp[i-1][j]) dp[i][j] = 1; if(j >= 1 && c[i+j] == b[j] && dp[i][j-1]) dp[i][j] = 1; } } if(dp[len1][len2]) printf("Data set %d: yes\n",cas++); else printf("Data set %d: no\n",cas++); } return 0;}
0 0
- POJ 2192 Zipper
- poj 2192 Zipper
- poj 2192 Zipper DP
- Poj 2192 Zipper
- DFS poj 2192 zipper
- poj 2192 zipper
- POJ-2192-Zipper
- poj 2192 Zipper
- POJ 2192 Zipper
- POJ 2192 Zipper
- poj 2192 zipper
- ACM POJ 2192 Zipper
- poj 2192 Zipper
- POJ 2192 Zipper
- POJ 2192 Zipper
- POJ---2192-Zipper
- POJ-2192 Zipper
- POJ 2192 Zipper
- 逆向工程实战--Afkayas.1
- 逻辑回归(代价函数,梯度下降) logistic regression--cost function and gradient descent
- Lightoj-1356 Prime Independence(质因子分解&&二分图最大独立集)
- error:const char *类型的实参与LPCWSTR类型的形参不兼容
- android中的@{} @+id ?/attr
- POJ 2192 Zipper
- AlertDialog.Builder setCancelable用法
- Spring 属性注入的实现原理
- 在Android Studio中打开DDMS
- 使用系统图片选择页面
- iOS UIView之间常用视图之间切换方式
- vim批量删除与插入
- 数列分段
- oracle性能优化总结