Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

高兴地1A了

Posted by luoyuqi at 2016-09-27 22:07:17 on Problem 3267
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int W=650,L=350;
int n,m,f[L],len[W];
char s[L],d[W][55];
int main()
{
	scanf("%d%d",&n,&m);
	getchar();
	gets(s+1);
	for(int i=1;i<=n;i++)
		gets(d[i]+1),len[i]=strlen(d[i]+1);
	f[0]=0;
	for(int i=1;i<=m;i++)
	{
		f[i]=f[i-1]+1;
		for(int j=1;j<=n;j++)
		{
			int z=len[j],k=i,c=0;
			while(z && k)
			{
				if(d[j][z]==s[k])z--;
				else c++;
				k--;
			}
			if(!z)f[i]=min(f[i],f[k]+c);
		}
	}
	printf("%d\n",f[m]);
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator