#include <iostream>
using namespace std;
int dx[4] = {0, -1, 1, 0};
int dy[4] = {-1, 0, 0, 1};
int arr[101][101];
int n, m;
int change(int y, int x) {
arr[y][x] = 0;
int size = 1;
for (int k = 0; k < 4; k++) {
int ny = y + dy[k];
int nx = x + dx[k];
if (ny >= 0 && ny < n && nx >= 0 && nx < m && arr[ny][nx] == 1) {
size += change(ny, nx);
}
}
return size;
}
int main() {
int k;
cin >> n >> m >> k;
for (int i = 0; i < k; i++) {
int a, b;
cin >> a >> b;
arr[a-1][b-1] = 1;
}
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (arr[i][j] == 1) {
int cur = change(i, j);
cnt = max(cnt, cur);
}
}
}
cout << cnt;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: