Pagini recente » Cod sursa (job #1931709) | Cod sursa (job #2370390) | Cod sursa (job #2207281) | Cod sursa (job #902793) | Cod sursa (job #638370)
Cod sursa(job #638370)
var v:array [0.. 500] of char;
n, t, max:longint;
ok:boolean;
f, g:text;
begin
assign (f, 'palm.in'); reset (f);
assign (g, 'palm.out'); rewrite (g);
while not eof (f) do
begin
inc (n); read (f, v[n]);
if ord(v[n]) <= ord(v[n-1]) then
begin
if (ok=false) and (ord(v[n-1]) >= ord(v[n-2])) then
begin ok:=true; t:=n-1; end; //a gasit un varf
if ok then
begin
if v[n]=v[2*t-n] then //inca suntem palindromi
begin
if 2*n-2*t+1>max then max:=2*n-2*t+1
end
else ok :=false;
end;
end
else ok:=false;
end;
writeln (g, max);
close (f); close (g);
end.