测试结果2: 通过本测试点|有效耗时156ms
测试结果3: 通过本测试点|有效耗时157ms
测试结果4: 通过本测试点|有效耗时172ms
测试结果5: 通过本测试点|有效耗时156ms
测试结果6: 通过本测试点|有效耗时156ms
测试结果7: 通过本测试点|有效耗时156ms
测试结果8:
测试结果9:
测试结果10: 通过本测试点|有效耗时156ms
提交代码:
const
dx:array[1..4]of longint=(0,0,-1,1);
dy:array[1..4]of longint=(1,-1,0,0);
var
i,j,k,m,n,tot,ans:longint;
f:array[-1..55,-1..55]of longint;
a:array[1..10000,1..2]of longint;
c:char;
procedure bfs(x,y:longint);
var
i,j,tail,head:longint;
begin
tail:=0;
head:=1;
a[1,1]:=x;
a[1,2]:=y;
tot:=0;
while tail<head do
begin
inc(tail);
if f[a[tail,1],a[tail,2]]=1 then inc(tot);
for i:=1 to 4 do
if f[a[tail,1]+dy[i],a[tail,2]+dx[i]]>=0 then
begin
inc(head);
a[head,1]:=a[tail,1]+dy[i];
a[head,2]:=a[tail,2]+dx[i];
end;
f[a[tail,1],a[tail,2]]:=-1;
end;
if tot>ans then ans:=tot;
end;
begin
assign(input,'1.in');reset(input);
fillchar(f,sizeof(f),200);
readln(m,n);
for i:=1 to m do
begin
for j:=1 to n do
begin
read(c);
case c of
'.':f[i,j]:=0;
'R':f[i,j]:=1;
end;
end;
readln;
end;
for i:=1 to m do
for j:=1 to n do
begin
if f[i,j]>=0 then
begin
bfs(i,j);
end
else
continue;
end;
writeln(ans);
end.