fork(4) download
  1. //Nông Dân John | THPT Nguyễn Quang Diêu
  2.  
  3. Var N,M: Integer;
  4. A: Array[0..1000,0..1000] of byte;
  5. F: Array[0..1000,0..1000] of integer;
  6. Procedure Enter;
  7. var i,j: Integer;
  8. begin
  9. Readln(M,N);
  10. For i:=1 to M do
  11. begin
  12. for j:=1 to N do read(A[i,j]);
  13. readln
  14. end;
  15. Fillchar(F, sizeof(F), 0);
  16. end;
  17. Function max(x,y,z: Integer): integer;
  18. begin
  19. max:=x;
  20. if y<max then max:=y;
  21. if z<max then max:=z;
  22. end;
  23. Procedure Process;
  24. var i,j: integer;
  25. begin
  26. For i:=1 to M do
  27. For j:=1 to N do
  28. if (A[i,j]=A[i-1,j])and(A[i,j]=A[i,j-1])and(A[i,j]=A[i-1,j-1]) then
  29. F[i,j]:=max(F[i-1,j],F[i,j-1],F[i-1,j-1])+1 else F[i,j]:=1;
  30. end;
  31. Procedure Print;
  32. var i,max,j: Integer;
  33. begin
  34. max:=F[1,1];
  35. for i:=1 to m do
  36. for j:=1 to n do
  37. if F[i,j]>max then max:=F[i,j];
  38. Write(max);
  39. end;
  40. Begin
  41. Assign(input, ''); reset(input);
  42. Assign(output, ''); rewrite(output);
  43. Enter;
  44. Process;
  45. Print;
  46. Close(input);
  47. Close(output)
  48. End.
Success #stdin #stdout 0s 3216KB
stdin
Standard input is empty
stdout
Standard output is empty