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

wa,是因为lcs错了?

Posted by Issue at 2005-12-03 03:57:14 on Problem 1159
#include <stdio.h>

int N;
char S[5002];
short f[2][5001];

int main()
{
	scanf("%d%s", &N, S+1);

	int i, j, current = 0;
	for (i = 1; i <= N; ++i){
		for (j = i; j <= N; ++j){
			if (S[i] == S[N + 1 - j])
				f[current][j] = f[!current][j - 1] + 1;
			else { 
				f[current][j] = f[current][j - 1];				
				if (f[current][j] < f[!current][j])
					f[current][j] = f[!current][j];
			}
		}
		current = !current;
	}
	printf("%d", N - f[!current][N]);

	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