记录编号 44260 评测结果 WWWWWWWWWW
题目名称 家族 最终得分 0
用户昵称 Gravatar4154 是否通过 未通过
代码语言 Pascal 运行时间 0.016 s
提交时间 2012-10-17 17:32:26 内存使用 0.17 MiB
显示代码纯文本
var a:array[0..101,0..101]of char;


    n,ans:integer;



procedure init;
var i,j:integer;
begin
  assign(input,'family.in');
  reset(input);
  readln(n);
  for i:=1 to n do
  begin
    for j:=1 to n do
      read(a[i,j]);
    readln;
  end;
  for i:=0 to n+1 do
  begin
    a[i,0]:=' ';
    a[i,n+1]:=' ';
    a[0,i]:=' ';
    a[n+1,i]:=' ';
  end;
  close(input);
end;

const go:array[1..4,1..2]of integer=((1,-1),
                                     (1,1),
                                     (-1,1),
                                     (-1,-1));

procedure dfs(x,y:integer);
var i,j,nx,ny:integer;
begin
  a[x,y]:=' ';
  for i:=1 to 4 do
  begin
    nx:=x+go[i,1];
    ny:=y+go[i,2];
    if (a[nx,ny]<>'*')and(a[nx,ny]<>' ') then dfs(nx,ny);
  end;



end;

procedure main;
var i,j,x,y:integer;
    flag:boolean;
begin
  repeat
    flag:=false;
    for i:=1 to n do
    begin
      for j:=1 to n do
        if (a[i,j]<>'*')and(a[i,j]<>' ') then
        begin
          flag:=true;
          x:=i;y:=j;
          break;
        end;
      if flag=true then break;
    end;
    if not flag then break;
    inc(ans);
    dfs(x,y);
  until not flag;
end;




begin
  init;
  main;
  assign(output,'family.out');
  rewrite(output);
  writeln(ans);
  close(output);


end.