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

急求牛人看看!!!!!! RTE 都n次了!!!

Posted by 20091101579 at 2011-03-03 22:38:34 on Problem 3051
#include <iostream>
using namespace    std;

int  Dir[4][2] = { {0,-1}, {0,1}, {-1,0}, {1,0} };
char Map[81][1001];
int  Count,Min;
int  W,H;

void DFS(int I,int J)
{
     Count++;
	 if(Min < Count)
		Min = Count;
     Map[I][J] = '.';
     for(int k=0; k<4; k++)
     {
         int x = I + Dir[k][0];
         int y = J + Dir[k][1];
         if( Map[x][y] == '*' && x>=0 && x<H && y>=0 && y<W )
			 DFS(x,y);
     }
     Count = 0;
}

int main()
{
    int i,j,k;
    while(cin>>W>>H)
    {
        //cin.get(); 
        for(i=0,Count=0,Min=0; i<H; i++)
            for(j=0; j<W; j++)
                cin>>Map[i][j];

        for(i=0; i<H; i++)
            for(j=0; j<W; j++)
                if(Map[i][j] == '*')
                    DFS(i,j);
		cout<<Min<<endl;
    }
    return 0;
}


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