Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

?

Posted by nj6519 at 2012-08-06 10:36:29 on Problem 2386
var s,m,n,i,j:integer;
    t:char;
    f:boolean;
    a:array[0..101,0..101]of boolean;
procedure search(i,j:integer);
begin
  a[i,j]:=false;
  if a[i,j+1]   then search(i,j+1);
  if a[i+1,j]   then search(i+1,j);
  if a[i+1,j+1] then search(i+1,j+1);
 // if a[i+1,j-1] then search(i+1,j-1);
 // if a[i-1,j-1] then search(i-1,j-1);
 // if a[i,j-1]   then search(i,j-1);
 // if a[i-1,j]   then search(i-1,j);
 // if a[i-1,j+1] then search(i-1,j+1);
end;

procedure counting;
begin
  i:=1;j:=0;
  while i+j=m+n do
  begin
    j:=j+1;
    if j>n then begin j:=1;i:=i+1;end;
    if a[i,j] then begin search(i,j);s:=s+1;end;
  end;
end;

begin
  readln(m,n);
  f:=false;s:=0;
  fillchar(a,sizeof(a),false);
  for i:=1 to m do begin for j:=1 to n do
  begin
    read(t);
    if t='W' then begin a[i,j]:=true;f:=true;end;
  end;readln;end;
  if f then counting;
  write(s);
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator