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 |
为什么大家都不理我啊???In Reply To:请各位大牛帮我看看,测试数据好象已经没什么问题了,为什么还是WA啊?谢谢^_^ Posted by:benbenbeibei at 2006-04-01 22:00:28 > #include<iostream.h> > char blocks[20][21]; > bool visit[20][21]; > int num; > int W,H; > int x,y; > void markBlocks(int ,int); > void main() > { > int i,j; > cin>>W>>H; > while(W!=0 && H!=0) > { > for(i=0;i<H;i++) > { > for(j=0;j<W;j++) > { > visit[i][j]=false; > blocks[i][j]='0'; > } > } > cin.getline(blocks[0],20); > for(i=0;i<H;i++) > { > cin.getline(blocks[i],W+1,'\n'); > cin.getline(blocks[i+1],20,'\n'); > } > for(i=0;i<H;i++) > { > for(j=0;j<W;j++) > { > if(blocks[i][j]=='@') > { > x=i; > y=j; > break; > } > } > if(y==j) > break; > } > num=0; > markBlocks(x,y); > cout<<num<<endl; > cin>>W>>H; > } > } > void markBlocks(int x,int y) > { > if(visit[x][y]) > return; > else > { > visit[x][y]=true; > num++; > } > if(blocks[x+1][y]=='.') > markBlocks(x+1,y); > if(blocks[x-1][y]=='.') > markBlocks(x-1,y); > if(blocks[x][y+1]=='.') > markBlocks(x,y+1); > if(blocks[x][y-1]=='.') > markBlocks(x,y-1); > } > > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator