| ||||||||||
| 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 | |||||||||
为什么WA啊,,大牛帮我啊!#include <iostream>
using namespace std;
int main()
{
int N;
while(cin>>N)
{
char str1[5001],str2[5001];
cin>>str1;
int i,j,k;
for(i=N-1;i>=0;i--)
{
str2[i]=str1[N-i-1];
}
str2[N]='\0';
int l1[5000],l2[5000];
for(i=0;i<N;i++) l2[i]=(str1[0]==str2[0]);
for(i=0;i<N;i++)
{
for(j=0;j<N;j++) l1[j]=l2[j];
for(j=1;j<N;j++)
{
if(str1[i]==str2[j])
{
l2[j]=l1[j-1]+1;
}else{
l2[j]=l1[j]>l2[j-1]?l1[j]:l2[j-1];
}
}
}
cout<<N-l2[N-1]<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator