POJ 3267 The Cow Lexicon
来源:互联网 发布:2017淘宝骗保师 编辑:程序博客网 时间:2024/05/23 19:13
Description
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.
Input
Line 2: L characters (followed by a newline, of course): the received message
Lines 3..W+2: The cows' dictionary, one word per line
Output
Sample Input
Sample Output
2Source
USACO 2007 February Silver#include <cstdio>
#include <cstring>
using namespace std;
int n,m;
char wen[500];
int dp[500];
struct dict
{
char word[100];
char theLastLaw;
int len;
}D[800];
int main()
{
scanf("%d%d",&n,&m);
getchar();
for(int i=1;i<=m;i++)
{
scanf("%c",&wen
}
for(int i=0;i<n;i++)
{
scanf("%s",D
D
D
}
memset(dp,0,sizeof(dp));
for(int i=1;i<=m;i++)
{
dp
for(int j=0;j<n;j++)
{
if(wen
{
// cout<<i<<": "<<wen
int flag=D[j].len-1,delet=0,pos=-1;
for(int k=i;k>0;k--)
{
if(wen[k]==D[j].word[flag])
flag--;
else
delet++;
if(flag<0){ pos=k; break;}
}
// cout<<"the flag: "<<flag<<" catch end with: "<<pos<<" , delet is: "<<delet<<endl;
if(flag<0)
{
if(pos==-1) pos=0;
dp
}
}
}
}
printf("%d\n",dp
return 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
- Asp.Net MVC4入门指南(7):给电影表和模型添加新字段
- HDOJ 4731 Minimum palindrome
- Asp.Net MVC4入门指南(8):给数据模型添加校验器
- POJ 1836 Alignment
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- POJ 3267 The Cow Lexicon
- Asp.Net MVC4入门指南(9):查询详细信息和删除记录
- DataGuard小结--1
- POJ 1054 The Troublesome Frog
- Asp.Net MVC4入门指南(10):第三方控件Studio for ASP.NET Wijmo MVC4 工具应用
- POJ 3280 Cheapest Palindrome
- POJ 1191 棋盘分割
- 2013 北京 QCon热点分享
- OpenCV学习笔记[1]初探OpenCV