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了几次,各种错误,晕死,改了几次终于ac了#include <iostream> #include <cstring> #include <string> using namespace std; char s1[5000],s2[5000]; short res[5001][5001]; int main() { int n; while(cin>>n) { cin>>s1; memset(res,0,sizeof(res)); for(int i=n-1,j=0;i>=0;--i,++j)s2[j]=s1[i]; for(int i=0;i<n;++i) for(int j=0;j<n;++j) { if(s1[i]==s2[j])res[i+1][j+1]=res[i][j]+1; else res[i+1][j+1]=max(res[i+1][j],res[i][j+1]); } cout<<n-res[n][n]<<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