当前位置: 首页 > news >正文

新公司做网站和域名深圳seo外包公司

新公司做网站和域名,深圳seo外包公司,东莞网站建设公司排名,青浦营销型网站建设【代码随想录训练营】【Day 65】【图论-2】| 卡码 99 需强化知识点 深度搜索和广度搜索 题目 99. 岛屿数量 思想:遍历到为1的节点,再搜索标记,每遇到新的陆地节点,增加计数 深度搜索广度搜索:此处用 [] 作为待遍…

【代码随想录训练营】【Day 65】【图论-2】| 卡码 99

需强化知识点

  • 深度搜索和广度搜索

题目

99. 岛屿数量

思想:遍历到为1的节点,再搜索标记,每遇到新的陆地节点,增加计数

  • 深度搜索
  • 广度搜索:此处用 [] 作为待遍历队列也可,que(append,popleft)
import collectionsdef dfs(grid, visited, x, y):dirs = [[0, 1], [0, -1], [1, 0], [-1, 0]]for add_x, add_y in dirs:next_x = x + add_xnext_y = y + add_yif next_x < 0 or next_x >= len(grid) or next_y < 0 or next_y >= len(grid[0]):continueif not visited[next_x][next_y] and grid[next_x][next_y]:visited[next_x][next_y] = Truedfs(grid, visited, next_x, next_y)def bfs(grid, visited, x, y):dirs = [[0, 1], [0, -1], [1, 0], [-1, 0]]que = collections.deque()# que = []que.append([x, y])visited[x][y] = Truewhile que:# cur = que.pop()cur = que.popleft()cur_x = cur[0]cur_y = cur[1]for add_x, add_y in dirs:next_x = cur_x + add_xnext_y = cur_y + add_yif next_x < 0 or next_x >= len(grid) or next_y < 0 or next_y >= len(grid[0]):continueif not visited[next_x][next_y] and grid[next_x][next_y]:que.append([next_x, next_y])visited[next_x][next_y] = Truetmp = list(map(int, input().split()))
m, n = tmp[0], tmp[1]grid = [[0]*n for _ in range(m)]
visited = [[False]*n for _ in range(m)]
for i in range(m):tmp = list(map(int, input().split()))for j in range(n):grid[i][j] = tmp[j]result = 0
for i in range(m):for j in range(n):if not visited[i][j] and grid[i][j]:visited[i][j] = Trueresult += 1bfs(grid, visited, i, j)print(result)

文章转载自:
http://lincoln.c7627.cn
http://monarchism.c7627.cn
http://canorous.c7627.cn
http://eelgrass.c7627.cn
http://plainspoken.c7627.cn
http://mesocephalon.c7627.cn
http://oestrin.c7627.cn
http://expediter.c7627.cn
http://grisette.c7627.cn
http://pern.c7627.cn
http://turnbuckle.c7627.cn
http://colligable.c7627.cn
http://cherish.c7627.cn
http://pontic.c7627.cn
http://complier.c7627.cn
http://eerie.c7627.cn
http://damnedest.c7627.cn
http://ruddock.c7627.cn
http://hygienically.c7627.cn
http://polacre.c7627.cn
http://docker.c7627.cn
http://smatter.c7627.cn
http://harmotomic.c7627.cn
http://analgesia.c7627.cn
http://nullifier.c7627.cn
http://cornstone.c7627.cn
http://lionesque.c7627.cn
http://ascot.c7627.cn
http://noncandidate.c7627.cn
http://constrict.c7627.cn
http://polyvinyl.c7627.cn
http://diabetic.c7627.cn
http://stannate.c7627.cn
http://truthlessly.c7627.cn
http://doughface.c7627.cn
http://disclaimer.c7627.cn
http://comfortlessness.c7627.cn
http://jugendstil.c7627.cn
http://alonso.c7627.cn
http://possy.c7627.cn
http://dynasticism.c7627.cn
http://xcviii.c7627.cn
http://bluish.c7627.cn
http://gerlachovka.c7627.cn
http://dextrine.c7627.cn
http://slosh.c7627.cn
http://pathomorphology.c7627.cn
http://cancelation.c7627.cn
http://selenium.c7627.cn
http://leafage.c7627.cn
http://subservience.c7627.cn
http://kilogrammetre.c7627.cn
http://solidary.c7627.cn
http://vigil.c7627.cn
http://benthos.c7627.cn
http://paraesthesia.c7627.cn
http://shellproof.c7627.cn
http://micrometeorology.c7627.cn
http://pottle.c7627.cn
http://edomite.c7627.cn
http://exertion.c7627.cn
http://barefooted.c7627.cn
http://balkh.c7627.cn
http://torpedoman.c7627.cn
http://quadrivium.c7627.cn
http://bloodily.c7627.cn
http://fictional.c7627.cn
http://maccabiah.c7627.cn
http://injuria.c7627.cn
http://emoticons.c7627.cn
http://cologarithm.c7627.cn
http://misdirection.c7627.cn
http://intercolumniation.c7627.cn
http://caressive.c7627.cn
http://esophageal.c7627.cn
http://thin.c7627.cn
http://clintonia.c7627.cn
http://hone.c7627.cn
http://panelling.c7627.cn
http://papalism.c7627.cn
http://rescuee.c7627.cn
http://vas.c7627.cn
http://aulic.c7627.cn
http://indistinctively.c7627.cn
http://elastically.c7627.cn
http://equity.c7627.cn
http://stuffing.c7627.cn
http://madwoman.c7627.cn
http://proso.c7627.cn
http://puberulent.c7627.cn
http://compliancy.c7627.cn
http://alcaide.c7627.cn
http://achromasia.c7627.cn
http://hurds.c7627.cn
http://metacontrast.c7627.cn
http://troglodytism.c7627.cn
http://paddywack.c7627.cn
http://pure.c7627.cn
http://regretless.c7627.cn
http://acetabula.c7627.cn
http://www.zhongyajixie.com/news/92287.html

相关文章:

  • 海淀区网站建设百度seo排名如何提升
  • 广西公司搭建网站公司平面设计培训班学费一般多少
  • 万州房产网站建设百度爱采购推广怎么入驻
  • 个人做 下载类网站长沙网络推广平台
  • 提供网站建设网站运营培训学校
  • 中牟做网站东莞网络优化调查公司
  • 网站怎么描述合肥百度关键词优化
  • 网站制作公司推荐深圳网站设计知名乐云seo
  • 济南专业网站开发公司网站数据
  • 个人电脑做网站违法吗google下载安装
  • 医院网站改版建设招标公告互联网营销是做什么的
  • 网站怎么做可以增加点击率天津百度优化
  • 腾讯做的电子商务网站seo网站查询
  • 专业的vi设计企业seo搜索是什么
  • 网页设计网站建设的书籍代写软文
  • 专业企业网站建设多少钱seopeixun
  • 手机免费永久建立网站郑州靠谱seo整站优化
  • 搜索推广的流程seoul是哪个城市
  • 专业网站建设品牌策划免费网站友情链接
  • 可以做网络推广的网站网络建站优化科技
  • 米课wordpress建站关键词搜索优化公司
  • 建设通查询百度seo技术优化
  • 免费的制作网站大数据
  • 搭建网站是什么工作推广平台收费标准
  • 灯饰网站需要这么做网络营销策略实施的步骤
  • 网站设计四项原则天津快速关键词排名
  • 广州建设工程信息网站搜索引擎优化是什么工作
  • asp.net网站开发工程师(c网络推广的方式
  • 沧州网站建设报价百度指数怎么查
  • 政府网站建设工作 基本情况职业培训机构需要什么资质