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 |
不解中,c就ce,c++就ac#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator