| ||||||||||
| 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 | |||||||||
Re:狂晕中,实在找不到错啊,但还是WA,哪位大哥帮忙看下有什么问题In Reply To:狂晕中,实在找不到错啊,但还是WA,哪位大哥帮忙看下有什么问题 Posted by:zhangli00 at 2007-05-09 14:30:56 > #include <iostream>
> using namespace std;
> int M,N;
> int b[102][102];
> int a[8][2]={1,1,1,0,1,-1,0,1,0,-1,-1,1,-1,0,-1,1};
> void DFS(int m,int n){
> b[m][n]=0;
> for(int t=0;t<8;t++){
> if(b[m+a[t][0]][n+a[t][1]]==1)
> DFS(m+a[t][0],n+a[t][1]);
> }
> }
> int main(){
> //freopen("a.in","r",stdin);
> int i,j,count;
> char ch;
> while(cin>>M>>N&&(M!=0||N!=0)){
> count=0;
> memset(b,0,sizeof(b));
> for(i=1;i<=M;i++)
> for(j=1;j<=N;j++){
> cin>>ch;
> if(ch=='W')b[i][j]=1;
> else b[i][j]=0;
> }
> for(i=1;i<=M;i++)
> for(j=1;j<=N;j++)
> if(b[i][j]==1){
> DFS(i,j);
> count++;
> }
> cout<<count<<endl;
> }
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator