• 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
  • 相关阅读:
    SqlDataAdapter 类
    新博开
    gcc编译C++程序

    抖动
    css3 导航效果
    javascript判断IE浏览器的版本
    CSS样式表继承详解
    css选择器
    鼠标样式
  • 原文地址:https://www.cnblogs.com/pandy/p/1447641.html
Copyright © 2020-2023  润新知