Cod sursa(job #334677)

Utilizator 05_YohnE1 La5c01 05_Yohn Data 27 iulie 2009 16:58:50
Problema Plantatie Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.66 kb
var v:array[1..500,1..500,1..500]of longint;
n,m,i,j,k,x,y,l:longint;

function max(i,j,k:integer):longint;
var aux:longint;
begin
aux:=v[i,j,k-1];
if v[i+1,j,k-1]>aux then aux:=v[i+1,j,k-1];
if v[i,j+1,k-1]>aux then aux:=v[i,j+1,k-1];
if v[i+1,j+1,k-1]>aux then aux:=v[i+1,j+1,k-1];
max:=aux;
end;

begin
assign(input,'plantatie.in');reset(input);
assign(output,'plantatie.out');rewrite(output);
read(n,m);
for i:=1 to n do
    for j:=1 to n do read(v[i,j,1]);

FOR K:=2 TO N DO
    for i:=1 to n-K+1 do
        for j:=1 to n-K+1 do v[i,j,k]:=max(i,j,k);

for i:=1 to m do begin
    read(x,y,l);
    writeln(v[x,y,l]);
end;
close(output);
end.