Cod sursa(job #635451)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 19 noiembrie 2011 11:45:18
Problema PalM Scor 20
Compilator fpc Status done
Runda .com 2011 Marime 0.74 kb
Program palm;
 var a:array [1..500] of char;
     i,j,max:integer;
     fi,fo:text;
procedure control();
var x,y,nr:integer;
begin
 x:=i-1; y:=i+1; nr:=1;
 while (a[x]=a[y]) and (ord(a[x])=ord(a[x+1])-1) and (x>=1) and (a[y] in ['a'..'z']) do begin
                                        dec(x); inc(y); nr:=nr+2;
                                        end;
 if nr>max then max:=nr;
  i:=y-1;
end;
begin
 assign(fi,'palm.in');
  assign(fo,'palm.out');
 reset(fi); rewrite(fo);
 read(fi,a); i:=1;
 while a[i] in ['a'..'z'] do begin
                             inc(i);
                             if (a[i-1]=a[i+1]) and (ord(a[i-1])=ord(a[i])-1) then control();
                             end;
 write(fo,max);
 close(fo);
end.