#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <string>
#include <map>
using namespace std;
//
// test.h
// test
//
// Created by 吴珝君 on 2018/12/31.
// Copyright © 2018年 闲着也是贤者. All rights reserved.
//
/************************************************************************/
/************************************************************************/
/*
并查集的实现
*/
/************************************************************************/
class Island
{
public:
//初始化并查集
int countIslands( vector<vector<int>> v)
{
if (v.empty())
{
return 0;
}
int maxrow = v.size();
int maxcol = v[0].size();
int res = 0;
for (int i = 0; i < maxrow; i++)
{
for (int j =0; j< maxcol; j++)
{
if (v[i][j] == 1)
{
res++;
inspect(v, i, j, maxrow, ma
算法第五节(第5部分: 孤岛问题的解决以及思考)
最新推荐文章于 2023-10-16 18:06:49 发布