1 条题解
-
0
#include <bits/stdc++.h> using namespace std; int dx[4] = {0, 1, 0, -1}; int dy[4] = {-1, 0, 1, 0}; int n, m, ans = 0, s = 0; char st[110]; bool a[1100][90]; void dfs(int x, int y) { s++; a[x][y] = false; for (int i = 0; i <= 3; i++) { int xx = x + dx[i]; int yy = y + dy[i]; if (xx >= 1 && xx <= n && yy >= 1 && yy <= m) if (a[xx][yy] == true) dfs(xx, yy); } } int main() { memset(a, false, sizeof(a)); scanf("%d%d", &m, &n); for (int i = 1; i <= n; i++) { scanf("%s", st + 1); for (int j = 1; j <= m; j++) if (st[j] == '*') a[i][j] = true; } for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (a[i][j] == true) { s = 0; dfs(i, j); ans = max(ans, s); } printf("%d", ans); return 0; }
- 1
信息
- ID
- 2237
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 9
- 标签
- 递交数
- 8
- 已通过
- 7
- 上传者