并查集 class UnionFind { public: UnionFind(vector<vector<char>>& grid) { int m = grid.size(), n = grid[0].size(); parent.assign(m * n, 0); rank.assign(m* n, 0); count = 0; // 注意先初始为0 for (int i = 0; i < m; ++i) { for (int...