giabinh

BaiCoNgonNhat

Nov 4th, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.88 KB | None | 0 0
  1. const fi='';
  2.       fo='';
  3.  
  4. var n,m,i,j,count:longint;
  5.     a:array[0..100,0..100]of char;
  6.     b:array[1..100,1..100]of boolean;
  7.  
  8. begin
  9.   assign(input,fi);reset(input);
  10.   assign(output,fo);rewrite(output);
  11.  
  12.   readln(n,m);
  13.   for i:=1 to n do
  14.     begin
  15.       for j:=1 to m do read(a[i,j]);
  16.       readln;
  17.     end;
  18.  
  19.   for i:=1 to n do a[i,0]:='.';
  20.   for i:=1 to m do a[0,i]:='.';
  21.   fillchar(b,sizeof(b),false);
  22.  
  23.   count:=0;
  24.   for i:=1 to n do
  25.     for j:=1 to m do
  26.       if (a[i,j]='#') and (not b[i,j]) then
  27.         begin
  28.           inc(count);
  29.           if a[i,j+1]='#' then
  30.             begin
  31.               b[i,j]:=true;
  32.               b[i,j+1]:=true;
  33.             end else
  34.           if a[i+1,j]='#' then
  35.             begin
  36.               b[i,j]:=true;
  37.               b[i+1,j]:=true;
  38.             end;
  39.         end;
  40.  
  41.   writeln(count);
  42.  
  43.   close(input);close(output);
  44. end.
Advertisement
Add Comment
Please, Sign In to add comment