| ||||||||||
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,i,j,f[5010][2]; char a[5010],b[5010]; cin>>n; for(i=1;i<=n;++i) { cin>>a[i]; b[n+1-i]=a[i]; } for(i=0;i<=n;++i) for(j=0;j<=n;++j) { if(i==0) f[j][0]=0; else if(j==0) f[j][1]=0; else if(a[i]==b[j]) { f[j][1]=f[j-1][0]+1; f[j-1][0]=f[j-1][1]; } else { f[j][1]=f[j-1][1]>f[j][0]?f[j-1][1]:f[j][0]; f[j-1][0]=f[j-1][1]; } } cout<<n-f[n][1]<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator