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

Re:没过去,不过算法应该正确的吧

Posted by vxk at 2003-11-15 14:41:07 on Problem 1159
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:
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