| ||||||||||
| 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,是因为lcs错了?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator