poj 3267 The Cow Lexicon
来源:互联网 发布:手机淘宝朋友代付 编辑:程序博客网 时间:2024/05/17 05:59
#include <stdio.h>#include <iostream>#include <string.h>#include <string>#include <algorithm>using namespace std;int min(int a,int b){ return a<b?a:b;}int main(){ int W,L; while(~scanf("%d%d%*c",&W,&L)) { int* dp=new int[L+1]; char* mesg=new char[L]; string* dict=new string[W]; cin>>mesg; for(int i=0;i<W;i++) cin>>dict[i]; dp[L]=0; for(int i=L-1;i>=0;i--) { dp[i]=dp[i+1]+1; for(int j=0;j<W;j++) { int len=dict[j].length(); if(len<=L-i&&dict[j][0]==mesg[i]) { int pm=i;//pm是给出字符的当前位置 int pd=0;//字典中字符的位置 while(pm<L) { if(dict[j][pd]==mesg[pm++])//每次不管怎样给出的字符pm都加1 pd++; if(pd==len)//如果字典中有字符被包含在字符串里面 { dp[i]=min(dp[i],dp[pm]+pm-i-len);//dp公式pm-i-len 是i~pm中错误的个数 break; } } } } } cout<<dp[0]<<endl; } return 0;}
0 0
- 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
- 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
- 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
- POJ 3267 The Cow Lexicon
- 【POJ 3267】 The Cow Lexicon
- The Cow Lexicon(POJ--3267
- Android Parcelable代码自动生成插件 Parcelable code generator
- Retrofit的简单使用
- css实现垂直居中
- 4*4矩阵按键控制数码管显示0-F
- 安卓表单数据的展示方式~!
- poj 3267 The Cow Lexicon
- Redis服务搭建及使用Keepalived实现主从双机热备
- java web —— JavaBeans
- jquery中使用javascript的with简化代码的写法
- 共同学习Java源代码-数据结构-HashSet(一)
- Java集合类详解
- 用开源软件搭建自己的物联网
- 走进Reac
- [编程题] 有趣的数字