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?

Posted by TN at 2005-01-16 14:25:17 on Problem 1458
Program PKU1458;
Const
   Maxn=500;
var
  a1,a2:array[1..maxn] of char;
  ans:array[0..maxn,0..maxn] of integer;
  i,j,m,n,n1,n2:integer;
  tc:char;
function max(s1,s2:integer):integer;
begin
if (s1>s2) then max:=s1 else max:=s2;
end;
begin
  while not eoln do
    begin
      n1:=0;n2:=0;
      while not eoln do
        begin
          inc(n1);
          read (a1[n1]);
          if a1[n1]=' ' then begin dec(n1);break;end;
        end;
      tc:=' ';
      while (tc=' ') or (tc=#9) or (tc=#10) or (tc=#13) do
         read (tc);
      n2:=1;
      a2[1]:=tc;
      while not eoln do
        begin
          inc(n2);
          read (a2[n2]);
        end;
      readln;
      fillchar (ans,sizeof(ans),0);
      for i:=1 to n1 do
        for j:=1 to n2 do
        if a1[i]=a2[j] then ans[i,j]:=ans[i-1,j-1]+1 else
        ans[i,j]:=max(ans[i-1,j],ans[i,j-1]);
      writeln (ans[n1,n2]);
  end;
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