zoukankan      html  css  js  c++  java
  • FloodZJFC Weekly 5

     

    题目描述

    The Flood come from the border of the map, so tell me the area without flood...Do u think it's easy ?

    输入描述

        First T(<=100) as T case...
    Then M(<=100),N(<=100) as the size of Map...
    Then the map coming...
    '#' as the wall and it's enough high to against flood
    '.' as the land

    输出描述

        Show the number of the point without flood...

    样例输入

    2
    3 3
    .#.
    #.#
    .#.
    4 4
    ####
    #..#
    #..#
    ####

    样例输出

    1
    4

    比较easy的搜索题,有一种比较好的方法是在地图边缘添点,然后在(0,0)处开始搜索,记录被淹过的面积以及大坝的总长,最后相减得到未淹过的面积。当然也可以遍历每个未被访问的陆地,对每个点实行宽搜,如果宽搜中出现越界的判定,则说明未被大坝包围,否则记录在改次搜索中结点的总数,最后累加得到结果。

    我的代码写的比较麻烦,对4个边界上的点进行深搜,并处理(将访问到的“.”--->"#"),最后统计地图中"."的个数并是结果了

    代码如下:

    Code
  • 相关阅读:
    android:screenOrientation属性详解
    Android APP混淆后,友盟分享功能出错的解决办法
    Android 混淆出错各种解决办法
    转一个工作三年的Android开发人员的思考
    Android 工程混淆后无法找到自定义控件类的解决方案
    Android Studio无法启动的解决方案 cannot start or open
    niz键盘windows键失效的解决办法:恢复出厂设置
    决策树学习资料
    人工智能行业发展趋势
    转:深度聚类算法研究综述(A Survey of Deep Clustering Algorithms)
  • 原文地址:https://www.cnblogs.com/pandy/p/1447641.html
Copyright © 2011-2022 走看看