POJ——2250 Compromise
来源:互联网 发布:淘宝怎么一键复制宝贝 编辑:程序博客网 时间:2024/06/06 02:52
就是最长公共子序列
#include <cstdio>#include <cstring>#include <iostream>using namespace std;// const int N=3500;char str1[105][35],str2[105][35];int main(){//freopen("text.txt","r",stdin);while(scanf("%s",str1[0])!=EOF&&str1[0][0]!='#'){int len1=1;while(scanf("%s",str1[len1])==1&&str1[len1][0]!='#')len1++;int len2=0;while(scanf("%s",str2[len2])==1&&str2[len2][0]!='#')len2++;int c[105][105];for(int i=1;i<=len1;i++)c[i][len2]=0;for(int i=1;i<=len2;i++)c[len1][i]=0;int i,j;for(i=len1-1;i>=0;i--)for(j=len2-1;j>=0;j--)if(strcmp(str1[i],str2[j])==0){c[i][j]=c[i+1][j+1]+1;s[i][j]=1;}else {s[i][j]=0;if(c[i][j+1]>c[i+1][j])c[i][j]=c[i][j+1];else c[i][j]=c[i+1][j];}int t=0,w=0;for(i=0;i<len1;i++)for(j=0;j<len2;j++)if(s[i][j]==1&&c[i][j]==c[0][0]-w){printf("%s ",str1[i]);w++;t=j+1;break;}putchar(10);}return 0;}
0 0
- POJ——2250 Compromise
- poj 2250 Compromise
- poj 2250 Compromise
- Poj 2250 Compromise
- poj 2250 Compromise
- 周赛 POJ 2250 Compromise
- poj 2250 Compromise
- poj 2250 Compromise
- POJ 2250 Compromise(LCS问题)
- poj 2250 Compromise (LCS)
- poj 2250 Compromise(LCS)
- POJ 1015 Jury Compromise——01背包变形
- poj Compromise
- POJ2250——Compromise
- POJ 2250--Compromise(LCS以及路径记录)
- poj 2250 Compromise(DP)
- poj 2250 Compromise(动归)
- Compromise - POJ 2250 UVa 531 dp
- 数据挖掘十大算法--浅谈Adaboost算法
- UVA - 11489 Integer Game (博弈)
- linux 查找目录或文件
- 为什么ListView点击反应迟钝
- CSSOM视图模式(CSSOM View Module)
- POJ——2250 Compromise
- 度金互联网金融社区:互联网金融未来的三种发展方向
- stat函数与结构体(文件信息)
- Android.mk中打印输出信息
- linux学习地址
- 编写接口测试的测试用例体会
- How to Create an Video Player in jQuery, HTML5 & CSS3
- iPhone发布内测程序的几种方法
- 黑马程序员--我以为18岁的我出去拿个8、9千就差不多了,没想到...haha~~