Pagini recente » Cod sursa (job #1083053) | Cod sursa (job #322091) | Cod sursa (job #889150) | Cod sursa (job #2214721) | Cod sursa (job #263087)
Cod sursa(job #263087)
var A:array[1..501,1..501,1..501] of longint;
n,m,i,j,k,x,y:integer;
function max(x,y:longint):longint;
begin
if (x>y) then max:=x
else max:=y;
end;
begin
assign(input,'plantatie.in');
assign(output,'plantatie.out');
reset(input);
rewrite(output);
readln(n,m);
for i:=1 to n do
for j:=1 to n do read(A[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
A[i,j,k]:=max(max(A[i,j,k-1],A[i,j+1,k-1]),max(A[i+1,j,k-1],A[i+1,j+1,k-1]));
for i:=1 to m do
begin
readln(x,y,k);
writeln(A[x,y,k]);
end;
close(input);
close(output);
end.