zoukankan      html  css  js  c++  java
  • 拯救OIBH总部

    题意

    OIBH被突来的洪水淹没了>.<还好OIBH总部有在某些重要的地方起一些围墙,用*号表示,而一个封闭的*号区域洪水是进不去的……现在给出OIBH的围墙建设图,问OIBH总部没被淹到的重要区域(由"0"表示)有多少。


    分析

    做法,周围一圈撒“种子”,然后将能蔓延的全部遍历掉就行了


    var
    zfc:ansistring;
    i,j,x,y,tj:longint;
    a:array[-1..501,-1..501]of char;


    procedure s(i,j:longint);
    var
    w:longint;
    begin
        if a[i,j]='0' then a[i,j]:='1' else exit;
        s(i+1,j);
        s(i-1,j);
        s(i,j+1);
        s(i,j-1);
    end;




    begin
        while not eof(input) do
        begin
            read(zfc);
            readln;
            inc(i);
            for j:=1 to length(zfc) do
            a[i,j]:=zfc[j];
            y:=length(zfc);
        end;
        x:=i;
        for i:=1 to x do
        begin
            if a[i,1]='0' then s(i,1);
            if a[i,y]='0' then s(i,y);
        end;
        for i:=1 to y do
        begin
            if a[1,i]='0' then s(1,i);
            if a[x,i]='0' then s(x,i);
        end;
        for i:=1 to x do
        for j:=1 to y do
        if a[i,j]='0' then inc(tj);
        writeln(tj);
    end.

  • 相关阅读:
    指针
    使用函数
    数组,切片和字典
    CUDA 进阶学习
    makefile 常用函数
    内存(RAM或ROM)和FLASH存储的真正区别总结
    射频,系带,调制解调器
    固态激光雷达
    毫米波雷达
    对比感知技术的硬件或者算法的关键技术指标
  • 原文地址:https://www.cnblogs.com/YYC-0304/p/9500153.html
Copyright © 2011-2022 走看看