POJ 3267 The Cow Lexicon
2012-12-03 22:27
405 查看
这道题我先读错了题,然后又是推错了方程。。。额。。智商捉急啊。。。。
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; char str[320],dic[620][40]; int w,l; int main() { int i,j,t1,t2; int d[320]; scanf("%d%d",&w,&l); getchar(); scanf("%s",str); for (i=0; i<w; i++) scanf("%s",dic[i]); memset(d,0,sizeof(d)); d[0]=0; for (i=1; i<=l; i++) { d[i]=d[i-1]+1; for (j=0; j<w; j++) { t1=strlen(dic[j])-1; t2=i-1; while (t2 >= 0 && t1 >= 0) { if (dic[j][t1] == str[t2]) { t1--; } t2--; } if (t1 == -1) { d[i]=d[i]<d[t2+1]+i-t2-1-strlen(dic[j])?d[i]:d[t2+1]+i-t2-1-strlen(dic[j]); } } } printf("%d\n",d[l]); }
相关文章推荐
- POJ 3267 The Cow Lexicon
- POJ 3267.The Cow Lexicon
- POJ_3267_The Cow Lexicon ( DP )
- POJ 3267 The Cow Lexicon 简单dp
- poj 3267 The Cow Lexicon
- POJ 3267:The Cow Lexicon 字符串匹配dp
- POJ-3267-The Cow Lexicon
- poj-3267 The Cow Lexicon【dp】
- poj 3267 -- The Cow Lexicon
- POJ 3267-The Cow Lexicon (动态规划)
- POJ 3267 The Cow Lexicon
- poj 3267 The Cow Lexicon 初级-》动态规划
- poj 3267 The Cow Lexicon (DP)
- poj_3267 The Cow Lexicon(dp)
- POJ - 3267 The Cow Lexicon 字符串匹配 (dp)
- POJ 3267 The Cow Lexicon (dp)
- POJ 3267:The Cow Lexicon 字符串匹配dp
- 【poj 3267】The Cow Lexicon 题意&题解&代码(C++)
- POJ 3267 The Cow Lexicon(DP单词匹配)
- poj 3267 The Cow Lexicon E[j]=opt{D+w(i,j)}