Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
?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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator