HBC24388OperatingonaGraph[USACO 2013 Feb S]Perimeter题解

季陌殇 算法基础篇 75 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
Farmer John has arranged N hay bales (1

Farmer John has arranged N hay bales (1 <= N <= 50,000) in the middle of one of his fields. If we think of the field as a 1,000,000 x 1,000,000 grid of 1 x 1 square cells, each hay bale occupies exactly one of these cells (no two hay bales occupy the same cell, of course).  FJ notices that his hay bales all form one large connected region, meaning that starting from any bale, one can reach any other bale by taking a series of steps either north, south, east, or west onto directly adjacent bales. The connected region of hay bales may however contain "holes" -- empty regions that are completely surrounded by hay bales.   Please help FJ determine the perimeter of the region formed by his hay bales. Note that holes do not contribute to the perimeter.

HBC24388OperatingonaGraph[USACO 2013 Feb S]Perimeter题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC24388OperatingonaGraph[USACO 2013 Feb S]Perimeter题解