HBC24849brz的雪糕,枚举,前缀和,尺取法[USACO 2009 Oct G]Invasion of the Milkweed题解

素流年 算法基础篇 42 0
不断提升技能,才能在职场中立于不败之地!全网最全C++题库,助您成为编程领域的佼佼者。
Farmer John has always done his best to keep the pastures full of luscious, delicious healthy grass for the cows. He has lost the battle, though, as the evil milkweed has attained a foothold in the northwest part of his farm. The pasture, as usual, is partitioned into a rectilinear grid of height Y (1

Farmer John has always done his best to keep the pastures full of luscious, delicious healthy grass for the cows. He has lost the battle, though, as the evil milkweed has attained a foothold in the northwest part of his farm. The pasture, as usual, is partitioned into a rectilinear grid of height Y (1 <= Y <= 100) and width X (1 <= X <= 100) with (1,1) being in the lower left corner (i.e., arranged as a normal X,Y coordinate grid). The milkweed has initially begun growing at square (Mx,My). Each week the milkweed propagates to all non-rocky squares that surround any square it already occupies, as many as eight more squares (both the rectilinear squares and the diagonals). After only one week in those squares, it is ready to move on to more squares. Bessie wants to enjoy all the grass she can before the pastures are taken over by milkweed. She wonders how long it can last. If the milkweed is in square (Mx,My) at time zero, at what time does it complete its invasion of the pasture (which, for the given input data, will always happen)? POINTS: 125 The pasture is described by a picture with '.'s for grass and '*'s for boulders, like this example with X=4 and Y=3: .... ..*. .**. If the milkweed started in the lower left corner (row=1, column=1), then the map would progress like this: .... .... MMM. MMMM MMMM ..*. MM*. MM*. MM*M MM*M M**. M**. M**. M**. M**M week 0 1 2 3 4 The milkweed has taken over the entire field after 4 weeks.

HBC24849brz的雪糕,枚举,前缀和,尺取法[USACO 2009 Oct G]Invasion of the Milkweed题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断挑战自我,才能突破极限!全网最全C++题库,让您在编程道路上越走越远。

标签: HBC24849brz的雪糕 枚举 前缀和 尺取法[USACO 2009 Oct G]Invasion of the Milkweed题解