/*
Time:2019.12.2
Author: Goven
type:深搜
err:RUNTIME ERR
ref:
*/
#include<iostream>
#include<cstring>
using namespace std;
int g[105][105];
bool visit[105][105];
int r[10005], c[10005];//RUNTIME ERR:数组开太小了
int dfs(int r, int c) {
if (visit[r][c] == true || g[r][c] == 0) return 0;
visit[r][c] = true;
return 1 + dfs(r + 1, c) + dfs(r - 1, c) + dfs(r, c + 1) + dfs(r, c - 1); //r\c边界不需要另外判断
}
int main()
{
memset(g, 0, sizeof(g));
memset(visit, false, sizeof(visit));
int n, m, k;
cin >> n >> m >> k;
for (int i = 0; i < k; i++) {
cin >> r[i] >> c[i];
g[r[i]][c[i]] = 1;
}
int res = 0;
for (int i = 0; i < k; i++) {
res = max(res, dfs(r[i], c[i]));
}
cout << res << endl;
return 0;
}
网友评论