7-109 3113 肿瘤面积

#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();
}

using point = pii;

void solve()
{
    point ul, dr;
    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];
        }
    }

    {
        bool bk = false;
        for (i32 i = 0; i < n; ++i)
        {
            for (i32 j = 0; j < n; ++j)
            {
                if (map[i][j] == 0)
                {
                    ul = {i, j};
                    bk = true;
                    break;
                }
            }
            if (bk)
            {
                break;
            }
        }
    }

    {
        bool bk = false;
        for (i32 i = n - 1; i >= 0; --i)
        {
            for (i32 j = n - 1; j >= 0; --j)
            {
                if (map[i][j] == 0)
                {
                    dr = {i, j};
                    bk = true;
                    break;
                }
            }
            if (bk)
            {
                break;
            }
        }
    }

    auto &[x1, y1] = ul;
    auto &[x2, y2] = dr;
    i32 x = x2 - x1 - 1;
    i32 y = y2 - y1 - 1;
    std::cout << x * y;
}
posted @ 2025-10-13 13:24  TPPPP72  阅读(4)  评论(0)    收藏  举报