The Cow Lexicon
Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 16 Accepted Submission(s) : 10
Few know that the cows have their own dictionary with W (1 ≤ W ≤ 600) words, each containing no more 25 of the characters 'a'..'z'. Their cowmunication system, based on mooing, is not very accurate; sometimes they hear words that do not make any sense. For instance, Bessie once received a message that said "browndcodw". As it turns out, the intended message was "browncow" and the two letter "d"s were noise from other parts of the barnyard.
The cows want you to help them decipher a received message (also containing only characters in the range 'a'..'z') of length L (2 ≤ L ≤ 300) characters that is a bit garbled. In particular, they know that the message has some extra letters, and they want you to determine the smallest number of letters that must be removed to make the message a sequence of words from the dictionary.
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int W,L,dp[301],i,j;
char word[301],dic[601][301];
cin>>W>>L>>word;
for(i=0;i<W;i++)
cin>>dic[i];
dp[L]=0;
for(i=L-1;i>=0;i--)
{
dp[i]=dp[i+1]+1;
for(j=0;j<W;j++)
{
int len=strlen(dic[j]);
if(L-i>=len&&word[i]==dic[j][0])
{
int i1=i,i2=0;
while(i1<L)
{
if(dic[j][i2]==word[i1++])
i2++;
if(i2==len)
{
dp[i]=min(dp[i],dp[i1]+i1-i-len);
break;
}
}
}
} }
cout<<dp[0]<<endl;
}
。
HDOJ-三部曲-1015-The Cow Lexicon的更多相关文章
-
POJ3267 The Cow Lexicon(DP+删词)
The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9041 Accepted: 4293 D ...
-
POJ 3267 The Cow Lexicon
又见面了,还是原来的配方,还是熟悉的DP....直接秒了... The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submis ...
-
POJ 3267:The Cow Lexicon(DP)
http://poj.org/problem?id=3267 The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submi ...
-
The Cow Lexicon
The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8815 Accepted: 4162 Descr ...
-
POJ3267——The Cow Lexicon(动态规划)
The Cow Lexicon DescriptionFew know that the cows have their own dictionary with W (1 ≤ W ≤ 600) wor ...
-
poj3267--The Cow Lexicon(dp:字符串组合)
The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8211 Accepted: 3864 D ...
-
BZOJ 1633: [Usaco2007 Feb]The Cow Lexicon 牛的词典
题目 1633: [Usaco2007 Feb]The Cow Lexicon 牛的词典 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 401 Solv ...
-
POJ 3267-The Cow Lexicon(DP)
The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8252 Accepted: 3888 D ...
-
bzoj1633 / P2875 [USACO07FEB]牛的词汇The Cow Lexicon
P2875 [USACO07FEB]牛的词汇The Cow Lexicon 三维dp 它慢,但它好写. 直接根据题意设三个状态: $f[i][j][k]$表示主串扫到第$i$个字母,匹配到第$j$个单 ...
随机推荐
-
cocoaPods 的使用
打开 终端 1. 移除系统自带的 因为该rub已经被和谐了 使用ruby.taobao.org MCJ:~ MCJ$ sudo gem sources -l *** CURRENT SOURCES * ...
-
HTMlhleper
@{ ViewBag.Title = "Index";} <h2>Index</h2> <div> @{ int id=12121; var I ...
-
第三篇——软件之殇,WE ARE THOUSANDS APART!
软件工程是一门工程性的学科,其目标主要是成功地建造一个大型软件系统.这其中包括:付出较低的开发成本:达到要求的软件功能:取得较好的软件性能:开发的软件易于移植:需要较低的维护费用:能按时完成开发任务, ...
-
WinForm程序用使用List对象绑定DataGridView数据源
1. 在用List<T>对象绑定DataGridView数据源属性的时候,数据源的内容不会动态更新,如果List<T>对象集合中的数据发生变化,那么数据控件的数据源是不会得到更 ...
-
python 操作 excel
python操作execel主要是读写 读 通过 http://pypi.python.org/pypi/xlrd 写 通过 http://pypi.python.org/pypi/xlwd 下载ta ...
-
ASP.NET 学习的总结
应用程序域 使用.Net建立的可执行程序*.exe,并没有直接承载到进程当中,而是承载到应用程序域(AppDomain)当中.应用程序域是.Net引入的一个新概念,它比进程所占用的资源要少,可以被看做 ...
-
VI 命令学习指南
ctrl+b 屏幕向后(上)移动一屏 ctrl+f 屏幕向前(下)移动一屏 ctrl+u 屏幕向后(上)移动半屏 ctrl+d 屏幕向前(下)移动半屏
-
[BZOJ 2165] 大楼 【DP + 倍增 + 二进制】
题目链接:BZOJ - 2165 题目分析: 这道题我读了题之后就想不出来怎么做,题解也找不到,于是就请教了黄学长,黄学长立刻秒掉了这道题,然后我再看他的题解才写出来..Orz 使用 DP + 倍增 ...
-
Android主页Activity对多个Fragment实现不同的沉浸式标题(图片或者文字标题)
提示:讲解的该例实现是 FragmentTabHost + Fragment 实现: 1.示例效果图: 2.场景需求: 如示例图所示,在首页实现轮播图的沉浸,而 “发现” 和“我的”页是标题的沉浸. ...
-
《DSP using MATLAB》Problem 5.37
证明过程: 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...