var i,j,m,n,x,y,s,max:longint; a,f,b:array[0..1000,0..1000] of longint; procedure nhap; var i:longint; begin readln(m,n); for i:=1 to m do begin for j:=1 to n do read(a[i,j]); readln; end; end; procedure tinh_f; begin for i:=1 to m do for j:=1 to n do f[i,j]:=f[i-1,j]+f[i,j-1]-f[i-1,j-1]+a[i,j]; end; function check(i,j,x,y:longint):boolean; begin s:=f[x,y]-f[i-1,y]-f[x,j-1]+f[i-1,j-1]; if s=0 then exit(true) else exit(false); end; procedure tim_hcn(t,j:longint); begin y:=j; while (y<n) and (check(i,j,i,y+1)=true) do inc(y); b[i,j]:=y-j+1; for x:=i+1 to m do begin while (y>=j) and (check(i,j,x,y)=false) do dec(y); // if yj then break; if b[i,j]<(x-i+1)*(y-j+1) then b[i,j]:=(x-i+1)*(y-j+1); end; end; procedure giai; begin for i:=1 to m do begin for j:=1 to n do if a[i,j]=1 then b[i,j]:=0 else tim_hcn(i,j); end; end; procedure xuat; var i:longint; begin for i:=1 to m do begin for j:=1 to n do write(b[i,j],' '); writeln; end; end; begin assign(input,'area0.inp'); reset(input); assign(output,'area0.out'); rewrite(output); nhap; tinh_f; giai; xuat; close(input); close(output); end.
* Chuyên dạy lập trình ONLINE cho học sinh THCS, THPT *.
Mọi giao lưu, trao đổi, xin liên hệ: Lê Quang Vinh - zalo: 037.803.8755.
Page: Lớp học Code Sky
Group FB1: Ôn thi HSG9 - THTB - TS10 chuyên tin
Group FB2: Học Scratch - Ôn thi Tin học trẻ bảng A
Thứ Sáu, 13 tháng 5, 2022
AREA0 PASCAL
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.