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

不解中,c就ce,c++就ac

Posted by xiaolijian at 2010-08-06 11:33:04 on Problem 3620
#include<stdio.h>
#include<string>


bool flag[105][105];
int num;

void DFS(int i,int j)
{
	if(flag[i][j])
	{
 	  num++;                            
 	  flag[i][j]=0;
 	  DFS(i-1,j);       
  	  DFS(i+1,j);
  	  DFS(i,j-1);
  	  DFS(i,j+1);
	}
}

int main()
{
	int i,j,m,n,t,x,y,temp;
	while(scanf("%d%d%d",&n,&m,&t)!=EOF)
	{
		memset(flag,0,sizeof(flag));
		
   		for(i=0;i<t;i++)
   		{
    		scanf("%d%d",&x,&y);
    		flag[x][y]=1;                     
   		}
   		temp=0;
   		for(i=1;i<=n;i++)
    		for(j=1;j<=m;j++)
     			if(flag[i][j])                           
     			{
      				num=0;
      				DFS(i,j);
      				if(num>temp)
       					temp=num;
     			}
   		printf("%d\n",temp);
	}
	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