POJ 1159 LCS 黑书练习题
来源:互联网 发布:淘宝卖手机需要3c 编辑:程序博客网 时间:2024/05/21 22:33
//使用short能过,使用int会超内存,公共个数总共也就5000,所以short是可行的 #include<iostream>using namespace std;char x[5005];char y[5005];short c[5005][5005];int len;int i,j; int comlen;void lcs(){ for(i=1;i<=len;i++) c[i][0]=0; for(j=1;j<=len;j++) c[0][j]=0; for(i=1;i<=len;i++) for(j=1;j<=len;j++){ if(x[i]==y[j]) c[i][j]=c[i-1][j-1]+1; else if(c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j]; else c[i][j]=c[i][j-1]; } comlen=c[len][len];}int main(){ while(scanf("%d%s",&len,x+1)!=EOF){ //将x逆序赋值给y for(i=1;i<=len;i++){ y[len-i+1]=x[i]; } lcs(); cout<<len-comlen<<endl; } return 0;}
- POJ 1159 LCS 黑书练习题
- poj 1159 Palindrome LCS
- poj 1159 Palindrome LCS
- poj 1159 LCS
- poj 1159 Palindrome (LCS)
- Palindrome POJ 1159 【LCS】
- poj 1159 (LCS)
- POJ-1159-Palindrome-lcs扩展
- POJ 1159 Palindrome (LCS)
- POJ 1159 Palindrome (LCS)
- POJ 1159 - Palindrome 优化空间LCS
- poj 1159 Palindrome 【LCS + 滚动数组】
- hdu 1159 && poj 1458 Common Subsequence (LCS)
- poj 1159 Palindrome --- LCS减内存
- hdu1513&&poj 1159 Palindrome(LCS+滚动数组)
- poj 1159 最长公共子串LCS
- poj 1159 Palindrome lcs+滚动数组
- POJ 1159 Palindrome(字符串变回文:LCS)
- 类的sizeof大小
- SVN 在线代码托管工具
- log4j与log4j.properties的配置说明
- JdbcTemplate调用存储过程的一些方法:
- 一个打通jni,java framework,application三层的练习
- POJ 1159 LCS 黑书练习题
- 我看懂的设计模式 Proxy,代理模式
- Java 一个问题
- log4j.properties配置详解
- 安装使用yum的downloadonly插件
- Windows环境下VMware虚拟机的自启动与自动关机
- android 图片效果相关
- heartbeat CRM管理程序功能示例
- android schedule policy