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 |
如此的滚动,为什么都是WC#include<iostream> #include<cstring> using namespace std; char str[5000]; int un_dif[2][5001]; int main() { int n,i,j; while(cin>>n) { cin>>str; memset(un_dif,0,sizeof(un_dif)); for(i=0;i<n;i++) { for(j=n-1;j>=0;j--) { if(str[i] == str[j]) un_dif[(i)%2][j-1] = un_dif[(i-1)%2][j]+1; else { if(un_dif[i%2][j]<un_dif[(i-1)%2][j-1]) un_dif[i%2][j-1] = un_dif[(i-1)%2][j-1]; else un_dif[i%2][j-1] = un_dif[i%2][j]; } cout<<un_dif[i%2][j-1]<<" "; } cout<<endl; } cout<<n-un_dif[(i-1)%2][j]<<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