HDU-2017 多校训练赛9-1010-Two strings
来源:互联网 发布:韩国网络电视成人直播 编辑:程序博客网 时间:2024/06/06 00:42
ACM模版
描述
题解
这个
这个题花费了一段时间,但是不得不说,这个题出得很有水平。尽管我讨厌他(ノω<。)ノ))☆.。讨厌
代码
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>#define clr(a, b) memset(a, b, sizeof(a))using namespace std;const int MAXN = 2555;char str1[MAXN];char str2[MAXN];int dp[MAXN][MAXN];int main(){ int T; scanf("%d", &T); while (T--) { clr(dp, 0); str1[0] = str2[0] = str1[1] = str2[1] = '#'; scanf("%s%s", str1 + 2, str2 + 2); int n = (int)strlen(str1 + 1); int m = (int)strlen(str2 + 1); dp[0][0] = dp[1][1] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (str2[j] == '.') { dp[i][j] |= dp[i - 1][j - 1] | dp[i][j - 1]; } else { if (str2[j] == '*') { dp[i][j] |= dp[i][j - 1] | dp[i][j - 2]; if (str1[i - 1] == str1[i]) { dp[i][j] |= dp[i - 1][j]; } } else { if (str1[i] == str2[j]) { dp[i][j] |= dp[i - 1][j - 1]; } else { dp[i][j] = 0; } } } } } if (dp[n][m]) { puts("yes"); } else { puts("no"); } } return 0;}
阅读全文
0 0
- HDU-2017 多校训练赛9-1010-Two strings
- HDU 6170 && 2017 多校训练:Two strings(DP)
- HDU-2017 多校训练赛10-1011-Two Paths
- 2017多校训练赛第九场 HDU 6170 Two String(dp)
- HDU-2017 多校训练赛6-1010-Gameia
- HDU-2017 多校训练赛10-1010-Schedule
- HDU-2017 多校训练赛9-1008-Numbers
- HDU-2017 多校训练赛9-补题
- HDU-2017 多校训练赛9-1006-Senior Pan
- 2017 第十场多校训练 HDU 6181 Two Paths 次短路+Dijkstra
- HDU-2017 多校训练赛1-1006-Function
- HDU-2017 多校训练赛1-1002-Balala Power!
- HDU-2017 多校训练赛1-补题
- HDU-2017 多校训练赛1-1003-Colorful Tree
- HDU-2017 多校训练赛2-1009-TrickGCD
- HDU-2017 多校训练赛2-1003-Maximum Sequence
- HDU-2017 多校训练赛2-1011-Regular polygon
- HDU-2017 多校训练赛2-补题
- (C++)unordered_map 与 map 的对比
- [pattest]1067. 试密码(20)
- 知历史,才可图未来 ——新书《未来简史》解读
- IO流复制多级文件
- 【Component】关于Ionic中的Component
- HDU-2017 多校训练赛9-1010-Two strings
- 结构体的使用
- 职业生涯系列
- 图的基本存储的基本方式一
- 数组中出现次数超过一半的数字
- hdu--6153(A Secret)
- [转]写给Krpano小白们的最最最入门级教程(二)
- 【容斥原理】Codeforces547C[Mike and Foam]题解
- 8.22最短路径讲解