ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1297. Palindrome

Can anybody give me the 2nd test ??? plzzzzzzzzz
Posted by Roshka 4 Dec 2008 01:09
It's ma prog and it works well, But I get WA at test 2...WHY???


Uses Math;
Var
  x,y:array[1..1000] of char;
  T:array[0..1000,0..1000] of integer;
  i,j,n,z,d:integer;
BEGIN
  n:=1;
  read(x[n]);
  while (not Eoln) do begin inc(n); read(x[n]); end;

  for i:=0 to n do T[0,i]:=0;
  for i:=0 to n do T[i,0]:=0;
   FOR i:=1 to n do
    FOR j:=1 to n do
     if ord(x[i])=ord(x[n-j+1]) then T[i,j]:=T[i-1,j-1]+1
                                else T[i,j]:=max(T[i-1,j],T[i,j-1]);
  d:=T[n,n]; i:=n; j:=n; z:=1;
  while (d<>0) do
    begin
      while (T[i-1,j]=d) do DEC(i);
      while (T[i,j-1]=d) do DEC(j);
      y[z]:=x[i]; INC(z);
      DEC(i); DEC(j); DEC(d);
    end;
  for i:=z-1 downto 1 do write(y[i]);
END.

Edited by author 04.12.2008 01:13