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:用DFS过了,但是自己都没搞懂为虾米过。。。。。。。。。In Reply To:用DFS过了,但是自己都没搞懂为虾米过。。。。。。。。。 Posted by:liushijian at 2009-12-20 10:27:43 这个简单的搜索就行了,也不用什么剪枝 int direct[][2]={{-1,0},{0,1},{1,0},{0,-1}}; int DFS(int i,int j) { int ii,jj; int k; visit[i][j]=1; ans++; for(k=0;k<4;k++) { ii=i+direct[k][0]; jj=j+direct[k][1]; if(ii>=0&&jj>=0&&ii<row&&jj<col&&!visit[ii][jj]&&map[ii][jj]=='.') { DFS(ii,jj); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator