7-103 3010 肿瘤检测

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using pii = std::pair<i32, i32>;
using pll = std::pair<i64, i64>;
using vi = std::vector<i32>;
using vll = std::vector<i64>;
using vpii = std::vector<pii>;
using vpll = std::vector<pll>;

void solve();

int main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}

void solve()
{
    i32 n;
    std::cin >> n;
    std::vector<std::vector<i32>> map(n);
    for (auto &item : map)
    {
        item.resize(n);
    }
    for (i32 i = 0; i < n; ++i)
    {
        for (i32 j = 0; j < n; ++j)
        {
            std::cin >> map[i][j];
        }
    }
    auto round = [&](i32 x, i32 y) {
        std::vector<i32> dir_x{1, -1, 0, 0};
        std::vector<i32> dir_y{0, 0, 1, -1};
        i32 count = 0;
        for (int i = 0; i < 4; ++i)
        {
            if (x + dir_x[i] >= 0 && x + dir_x[i] < n)
            {
                if (y + dir_y[i] >= 0 && y + dir_y[i] < n)
                {
                    if (map[x + dir_x[i]][y + dir_y[i]] <= 50)
                    {
                        ++count;
                    }
                }
            }
        }
        return count;
    };
    i32 c{0}, s{0};
    for (i32 i = 0; i < n; ++i)
    {
        for (i32 j = 0; j < n; ++j)
        {
            if (map[i][j] <= 50)
            {
                ++s;
                if (round(i, j) == 4)
                {
                    --c;
                }
            }
        }
    }
    std::cout << s << ' ' << s + c;
}
posted @ 2025-10-13 09:12  TPPPP72  阅读(5)  评论(0)    收藏  举报