比赛 |
搜索题... |
评测结果 |
AWWWAWAWWW |
题目名称 |
最大的湖 |
最终得分 |
30 |
用户昵称 |
helloworld123 |
运行时间 |
0.007 s |
代码语言 |
Pascal |
内存使用 |
0.20 MiB |
提交时间 |
2014-11-04 19:25:16 |
显示代码纯文本
program cogs155;
const
maxn=100;
dx:array[1..4] of longint=(-1,0,1,0);
dy:array[1..4]of longint=(0,-1,0,1);
var
x,y,i,j,n,m,k,ans:longint;
a:array[1..maxn,1..maxn] of longint;
function heshi(x,y:longint):boolean;
begin
if (x<=n)and(x>0)and(y<=m)and(y>0)and(a[x,y]=1)
then exit(true);
exit(false);
end;
procedure bfs(l,r:longint);
var
i,j,front,tail:longint;
q:array[1..maxn*maxn,1..2] of longint;
begin
front:=0; tail:=1;
q[1,1]:=l; q[1,2]:=r;
a[x,y]:=0;
while front<>tail do
begin
inc(front);
for i:=1 to 4 do
begin
x:=q[front,1]+dx[i];
y:=q[front,2]+dy[i];
if heshi(x,y) then
begin
a[x,y]:=0;
inc(tail);
q[tail,1]:=x; q[tail,2]:=y;
end;
end;
end;
if tail>ans then ans:=tail;
end;
begin
assign(input,'lake.in'); reset(input);
assign(output,'lake.out'); rewrite(output);
readln(n,m,k);
fillchar(a,sizeof(a),0);
for i:=1 to k do
begin
readln(x,y);
a[x,y]:=1;
end;
ans:=-maxlongint;
for i:=1 to n do
for j:=1 to m do
begin
if a[i,j]=1 then
begin
a[i,j]:=0;
bfs(i,j);
end;
end;
writeln(ans);
close(input); close(output);
end.