| ||||||||||
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 |
无限WA。。。求数据#include <iostream> #include <cstdio> using namespace std; int a[105][105]; int n,m; int dfs(int i,int j){ if(i<1 || i>n || j<1 || j>n || !a[i][j]) return 0; a[i][j]=false; return dfs(i+1,j)+dfs(i,j+1)+dfs(i-1,j)+dfs(i,j-1)+1; } int main(){ int i,j,k,ans=0; cin>>n>>m>>k; while(k--){ int x,y; cin>>x>>y; a[x][y]=true; } for(i=1;i<=n;i++) for(j=1;j<=m;j++) if(a[i][j]) ans=max(dfs(i,j),ans); cout<<ans<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator