比赛 |
20140714上午练习 |
评测结果 |
WWWWWWWW |
题目名称 |
城堡 |
最终得分 |
0 |
用户昵称 |
FoolMike |
运行时间 |
0.009 s |
代码语言 |
Pascal |
内存使用 |
0.18 MiB |
提交时间 |
2014-07-14 11:27:36 |
显示代码纯文本
var
d,c,e,n,m,ans,x1,y1:longint;
ch:char;
a,b:array[0..51,0..51]of integer;
k:array[0..2501]of integer;
procedure sousuo(x,y:longint);
var
i,j:longint;
begin
if (a[x,y] mod 2<1)and(b[x,y-1]=0) then
begin
b[x,y-1]:=c;
inc(k[c]);
sousuo(x,y-1);
end;
if (a[x,y] mod 4<2)and(b[x-1,y]=0) then
begin
b[x-1,y]:=c;
inc(k[c]);
sousuo(x-1,y);
end;
if (a[x,y] mod 8<4)and(b[x,y+1]=0) then
begin
b[x,y+1]:=c;
inc(k[c]);
sousuo(x,y+1);
end;
if (a[x,y]<8)and(b[x+1,y]=0) then
begin
b[x+1,y]:=c;
inc(k[c]);
sousuo(x+1,y);
end;
end;
begin
assign(input,'castle.in');
assign(output,'castle.out');
reset(input);
rewrite(output);
for d:=0 to 101 do
for e:=0 to 101 do
a[d,e]:=15;
read(n,m);
for d:=1 to m do
for e:=1 to n do
read(a[d,e]);
c:=0;
for d:=1 to m do
for e:=1 to n do
if b[d,e]=0 then
begin
inc(c);
inc(k[c]);
b[d,e]:=c;
sousuo(d,e);
end;
writeln(c);
ans:=0;
for c:=1 to c do
if k[c]>ans then ans:=k[c];
writeln(ans);
for e:=1 to n do
for d:=m downto 1 do
begin
if (b[d,e]<>b[d,e+1])and(k[b[d,e]]+k[b[d,e+1]]>ans) then
begin
x1:=d;y1:=e;ch:='E';
ans:=k[b[d,e]]+k[b[d,e+1]];
end;
if (b[d,e]<>b[d,e-1])and(k[b[d,e]]+k[b[d,e-1]]>ans) then
begin
x1:=d;y1:=e;ch:='W';
ans:=k[b[d,e]]+k[b[d,e-1]];
end;
if (b[d,e]<>b[d+1,e])and(k[b[d,e]]+k[b[d+1,e]]>ans) then
begin
x1:=d;y1:=e;ch:='N';
ans:=k[b[d,e]]+k[b[d+1,e]];
end;
if (b[d,e]<>b[d-1,e])and(k[b[d,e]]+k[b[d-1,e]]>ans) then
begin
x1:=d;y1:=e;ch:='S';
ans:=k[b[d,e]]+k[b[d-1,e]];
end;
end;
writeln(ans);
writeln(x1,' ',y1,' ',ch);
close(input);close(output);
end.