Skip to content

Commit eeca856

Browse files
authored
Update 0101.孤岛的总面积.md
这道题目的意思应该是计算孤岛个数吧,根据题意, 对于 5 6 1 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 这个输入,应该输出是1. 但是按照卡哥的代码,输出会是2,问题就出在应该是找到==1的陆地后,继续进行dfs,而不是直接count++ 我这边是只修改dfs的部分,还没修改bfs 的部分
1 parent 7aa973b commit eeca856

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

problems/kamacoder/0101.孤岛的总面积.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ int main() {
112112
int count = 0;
113113
for (int i = 0; i < n; i++) {
114114
for (int j = 0; j < m; j++) {
115-
if (grid[i][j] == 1) count++;
115+
if (grid[i][j] == 1){
116+
count++;
117+
dfs(grid,i,j);
118+
}
116119
}
117120
}
118121
cout << count << endl;

0 commit comments

Comments
 (0)