POJ 3620 Avoid The Lakes
ソースコード
bool lake[128][128]; int dfs(int x, int y) { if (!lake[y][x]) return 0; lake[y][x] = false; int res = 1; rep(i, 4) res += dfs(x + dx[i], y + dy[i]); return res; } int main() { int h, w, k; scanf("%d%d%d", &h, &w, &k); while (k--) { int x, y; scanf("%d%d", &y, &x); lake[y][x] = true; } int res = 0; erep(y, h) erep(x, w) chmax(res, dfs(x, y)); printf("%d\n", res); }