POJ 1159 Palindrome(DP)
来源:互联网 发布:linux dhcp服务器设置 编辑:程序博客网 时间:2024/06/09 18:00
真是无情,我都不知道为什么这样,感觉凑出来,n-原串和逆序串的LCS 就是答案。然后试一试的写了一发。就过了。。无情。。
dp用short定义就不会MTL 了。。。纪念一下自己稀里糊涂过了一题
#include <cstdio>#include <iostream>#include <algorithm>#include <cstring>using namespace std;char save[5005];char res[5005];short dp[5005][5005];int main(){ int n; while(scanf("%d",&n)!=EOF) { save[0]='#'; scanf("%s",save+1); for(int i=n;i>=1;i--) res[n-i+1]=save[i]; res[0]='@'; memset(dp,0,sizeof dp); for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(save[i]==res[j]) { dp[i][j]=dp[i-1][j-1]+1; } else dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } } printf("%d\n",n-dp[n][n]); } return 0;}
0 0
- dp poj 1159 Palindrome
- POJ 1159 Palindrome DP
- poj 1159 Palindrome 【DP】
- POJ 1159 Palindrome dp
- POJ 1159 Palindrome(DP)
- POJ 1159 Palindrome(DP)
- Palindrome - POJ 1159 dp
- POJ 1159 Palindrome DP
- POJ 1159 Palindrome dp
- POJ-1159-Palindrome -dp
- [POJ 1159]Palindrome[DP]
- poj 1159 dp Palindrome
- poj 1159 Palindrome dp 字符串
- POJ 1159-Palindrome(DP)
- POJ-1159-Palindrome(简单dp)
- POJ-1159 Palindrome (区间dp)
- poj 1159 Palindrome(DP)
- POJ 1159 Palindrome DP 滚动数组
- 洛谷 P1846 游戏
- 跳表(SkipList)与其在java中的使用
- 阶乘之和
- 二分搜索
- Windows下搭建PHP开发环境
- POJ 1159 Palindrome(DP)
- JAVA加密与解密
- c++运算符重载
- C++回顾之内联函数及新类型转换运算符
- 九度oj 题目1012:畅通工程
- c++流符号重载例子
- 狼找兔子
- vuforia结合unity3d开发AR的androidAPP总结(三)
- Java学习从菜鸟变大鸟之二 输入输出流(IO)