| ||||||||||
| 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 | |||||||||
Re:没过去,不过算法应该正确的吧In Reply To:没过去,不过算法应该正确的吧 Posted by:vxk at 2003-11-15 14:39:48 program pail;
{
主要是超时!!
}
type
CFT=array [0..5000] of integer;
Var
a,b:array [1..5000] of char;
C:array [1..2] of CFT;
n,k,j:integer;
Begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
Readln(n);
for k:=1 to n do
begin
read(a[k]);
b[n-k+1]:=a[k];
end;
for j:=1 to n do
begin
c[1]:=c[2];
for k:=1 to n do
begin
c[2][k]:=c[2][k-1];
if (a[j]=b[k])and(c[2][k]<c[1][k-1]+1) then c[2][k]:=c[1][k-1]+1;
if (a[j]<>b[k])and(c[2][k]<c[1][k]) then c[2][k]:=c[1][k];
end;
end;
writeln(n-c[2][n]);
End.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator