记录编号 |
137559 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[USACO Nov07] 最大的湖 |
最终得分 |
100 |
用户昵称 |
明天 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.005 s |
提交时间 |
2014-11-04 21:12:41 |
内存使用 |
0.33 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
using namespace std;
int n,m,k;
bool a[101][101];
const int dx[4]={-1,0,1,0};
const int dy[4]={0,1,0,-1};
int ans,temp;
void dfs(int i,int j)
{
a[i][j]=false;
temp++;
for (int k=0; k<4; k++)
{
int x,y;
x=i+dx[k]; y=j+dy[k];
if (x>=1 && x<=n && y>=1 && y<=m && a[x][y])
{
dfs(x,y);
}
}
}
int main()
{
freopen("lake.in","r",stdin);
freopen("lake.out","w",stdout);
scanf("%d%d%d",&n,&m,&k);
for (int i=1; i<=k; i++)
{
int x,y;
scanf("%d%d",&x,&y);
a[x][y]=true;
}
for (int i=1; i<=n; i++)
for (int j=1; j<=m; j++)
if (a[i][j])
{
temp=0;
dfs(i,j);
if (temp>ans) ans=temp;
}
printf("%d\n",ans);
return 0;
}