poj 1159 Palindrome (lcs,滚动数组)
来源:互联网 发布:cnc编程还是模具设计好 编辑:程序博客网 时间:2024/06/05 10:53
/*最少需要补充的字母数 = 原序列S的长度 — S和S'的最长公共子串长度*/# include <stdio.h># include <algorithm># include <iostream># include <string.h>using namespace std;int dp[2][5010];///滚动数组int main(){ char a[5010]; char b[5010]; int i,j,k,len; while(~scanf("%d",&len)) { scanf("%s",a); k=0; for(i=len-1;i>=0;i--) b[k++]=a[i]; memset(dp,0,sizeof(dp)); for(i=1;i<=len;i++) { for(j=1;j<=len;j++) { if(a[i-1]==b[j-1]) dp[1][j]=dp[0][j-1]+1; else dp[1][j]=max(dp[0][j],dp[1][j-1]); } for(j=1;j<=len;j++) dp[0][j]=dp[1][j]; } printf("%d\n",len-dp[1][len]); } return 0;}
1 0
- poj 1159 Palindrome 【LCS + 滚动数组】
- hdu1513&&poj 1159 Palindrome(LCS+滚动数组)
- poj 1159 Palindrome lcs+滚动数组
- poj 1159 Palindrome (lcs,滚动数组)
- POJ 1159 Palindrome(DP LCS&滚动数组)
- poj-1159-Palindrome【LCS】【滚动数组】
- POJ 1159 Palindrome【LCS+滚动数组】【水题】
- poj 1159 Palindrome lcs 滚动数组
- POJ 1159 Palindrome(lcs加滚动数组)
- poj 1159 Palindrome (DP:LCS+滚动数组)
- poj 1159 Palindrome LCS一维滚动数组优化
- HDU1513 Palindrome(LCS+滚动数组)
- Palindrome POJ1159 LCS+滚动数组
- POJ 1159 Palindrome(滚动数组)
- poj 1159 Palindrome LCS
- poj 1159 Palindrome LCS
- poj 1159 Palindrome (LCS)
- Palindrome POJ 1159 【LCS】
- html基础知识:form表单和框架
- linux的时间属性
- android init进程 init.rc
- 全排列的算法(三)——递减进位法
- 轻松实现一个操作ini文件的类
- poj 1159 Palindrome (lcs,滚动数组)
- 解说==frameworks/av/camera/
- Linux 下五款出色的流媒体客户端
- 开发者比备的12大开发资源
- 操作系统虚拟内存中的四种典型页替换算法(OPT,LRU,FIFO,Clock)
- Android 对话框
- NOIP的水题
- 正则表达式 —— 点(dot)
- C 算法精介----链表->双向链表