Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

如此的滚动,为什么都是WC

Posted by smzzw at 2013-01-22 15:28:19 on Problem 1159
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator