1 solutions
-
0
C++ :
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int f[3][160][160][160],ans=0,que[220],p,q,r; void init() { char ch[160]; int i,j,k; scanf("%d%d%d\n",&p,&q,&r); for (i=1;i<=q;i++) for (j=1;j<=p;j++) { scanf("%s",&ch); for (k=1;k<=r;k++) { if (ch[k-1]=='N') { f[0][i][j][k]=1; f[1][j][i][k]=1; f[2][k][i][j]=1; } } } } void work(int p1,int q1,int r1,int tmp) { int i,j,k,tail=0; for (i=1;i<=p1;i++) for (j=1;j<=q1;j++) for (k=1;k<=r1;k++) if (f[tmp][i][j][k]==1) f[tmp][i][j][k]=min(f[tmp][i][j-1][k-1],min(f[tmp][i][j][k-1],f[tmp][i][j-1][k]))+1; for (i=1;i<=q1;i++) for (j=1;j<=r1;j++) { memset(que,0,sizeof(que)); tail=0; for (k=1;k<=p1+1;k++) { while (f[tmp][k][i][j]<=f[tmp][que[tail]][i][j]&&tail>0) { ans=max(ans,4*f[tmp][que[tail]][i][j]*(k-que[tail-1]-1)); tail--; } que[++tail]=k; } } } int main() { init(); work(q,p,r,0); work(p,q,r,1); work(r,q,p,2); printf("%d",ans); return 0; }
Pascal :
program gift; var w,tot,mid,s,e,o,ans,p,q,r,i,j,k:longint; map:array [0..151,0..151,0..151] of char; dl,point:array [0..151] of longint; f:array [0..151,0..151,0..151] of longint; function min (a,b:longint):longint;inline; begin if a<b then exit(a) else exit(b); end; begin readln(p,q,r); for j:=1 to q do for i:=1 to p do begin for k:=1 to r do read(map[i,j,k]); readln; end; ans:=1; fillchar(f,sizeof(f),0); for i:=p downto 1 do for j:=q downto 1 do for k:=1 to r do if map[i,j,k]='P' then f[i,j,k]:=0 else f[i,j,k]:=min(min(f[i+1,j,k],f[i,j+1,k]),f[i+1,j+1,k])+1; for i:=1 to p do for j:=1 to q do begin tot:=0; for k:=1 to r+1 do begin while (tot>0)and(f[i,j,k]<f[i,j,dl[tot]]) do begin if ans<f[i,j,dl[tot]]*(k-dl[tot-1]-1) then ans:=f[i,j,dl[tot]]*(k-dl[tot-1]-1); dec(tot); end; inc(tot); dl[tot]:=k; end; end; fillchar(f,sizeof(f),0); for i:=p downto 1 do for k:=r downto 1 do for j:=1 to q do if map[i,j,k]='P' then f[i,j,k]:=0 else f[i,j,k]:=min(min(f[i+1,j,k],f[i,j,k+1]),f[i+1,j,k+1])+1; for i:=1 to p do for k:=1 to r do begin tot:=0; for j:=1 to q+1 do begin while (tot>0)and(f[i,j,k]<f[i,dl[tot],k]) do begin if ans<f[i,dl[tot],k]*(j-dl[tot-1]-1) then ans:=f[i,dl[tot],k]*(j-dl[tot-1]-1); dec(tot); end; inc(tot); dl[tot]:=j; end; end; fillchar(f,sizeof(f),0); for j:=q downto 1 do for k:=r downto 1 do for i:=1 to p do if map[i,j,k]='P' then f[i,j,k]:=0 else f[i,j,k]:=min(min(f[i,j+1,k],f[i,j,k+1]),f[i,j+1,k+1])+1; for j:=1 to q do for k:=1 to r do begin tot:=0; for i:=1 to p+1 do begin while (tot>0)and(f[i,j,k]<f[dl[tot],j,k]) do begin if ans<f[dl[tot],j,k]*(i-dl[tot-1]-1) then ans:=f[dl[tot],j,k]*(i-dl[tot-1]-1); dec(tot); end; inc(tot); dl[tot]:=i; end; end; writeln(ans*4); end.
- 1
Information
- ID
- 549
- Time
- 2000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By