Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
高兴地1A了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator