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

Re:用DFS过了,但是自己都没搞懂为虾米过。。。。。。。。。

Posted by feir8510 at 2010-01-14 21:14:43 on Problem 1979
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:
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