当前位置: 首页 > news >正文

Invasion of the Milkweed G

[USACO09OCT] Invasion of the Milkweed G

题目描述

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)?

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*MM**.  M**.  M**.  M**.  M**M
week  0    1    2    3    4

The milkweed has taken over the entire field after 4 weeks.

POINTS: 125

Farmer John一直努力让他的草地充满鲜美多汁的而又健康的牧草。可惜天不从人愿,他在植物大战人类中败下阵来。邪恶的乳草已经在他的农场的西北部份占领了一片立足之地。

草地像往常一样,被分割成一个高度为Y(1 <= Y <= 100), 宽度为X(1 <= X <= 100)的直角网格。(1,1)是左下角的格(也就是说坐标排布跟一般的X,Y坐标相同)。乳草一开始占领了格(Mx,My)。每个星期,乳草传播到已被乳草占领的格子四面八方的每一个没有很多石头的格(包括垂直与水平相邻的和对角在线相邻的格)。1周之后,这些新占领的格又可以把乳草传播到更多的格里面了。

Bessie想要在草地被乳草完全占领之前尽可能的享用所有的牧草。她很好奇到底乳草要多久才能占领整个草地。如果乳草在0时刻处于格(Mx,My),那么会在哪个时刻它们可以完全占领入侵整片草地呢?对给定的数据总是会发生。

输入格式

* Line 1: Four space-separated integers: X, Y, Mx, and My

* Lines 2…Y+1: Line y+1 describes row (Y+2-y) of the field with X characters (‘.’ for grass and ‘*’ for a boulder)

输出格式

* Line 1: A single integer that is the week number when the milkweed takes over the last remaining non-boulder square of the pasture.

样例 #1

样例输入 #1

4 3 1 1 
.... 
..*. 
.**.

样例输出 #1

4

相关文章:

  • Android:多线程下载网络图片
  • 【0257】关于pg内核shared cache invalidation messages (概念篇)
  • C语言之找单身狗
  • java SpringBoot2.7整合Elasticsearch(ES)7 进行文档增删查改
  • linux 生成 ca 证书
  • 体悟PyTorch的优雅
  • 毫无基础的人如何入门 Python ?
  • 十分钟GIS——geoserver+postgis+udig从零开始发布地图服务
  • hadoop使用公平调度器
  • 包装组件的优点和可能的挑战
  • 鸿蒙开发系列教程(十六)--日志处理
  • B2052 简单计算器(洛谷)
  • Vue3快速上手(二)VSCode官方推荐插件安装及配置
  • IDEA 推荐插件
  • 苹果macbook电脑删除数据恢复该怎么做?Mac电脑误删文件的恢复方法
  • 《网管员必读——网络组建》(第2版)电子课件下载
  • Docker 1.12实践:Docker Service、Stack与分布式应用捆绑包
  • iOS 颜色设置看我就够了
  • iOS编译提示和导航提示
  • Javascript 原型链
  • JS基础篇--通过JS生成由字母与数字组合的随机字符串
  • JS实现简单的MVC模式开发小游戏
  • Leetcode 27 Remove Element
  • magento2项目上线注意事项
  • PHP 的 SAPI 是个什么东西
  • React 快速上手 - 06 容器组件、展示组件、操作组件
  • scrapy学习之路4(itemloder的使用)
  • spring security oauth2 password授权模式
  • SQLServer之创建数据库快照
  • Tornado学习笔记(1)
  • TypeScript迭代器
  • 成为一名优秀的Developer的书单
  • 关于使用markdown的方法(引自CSDN教程)
  • 京东美团研发面经
  • 浅谈web中前端模板引擎的使用
  • 删除表内多余的重复数据
  • 【云吞铺子】性能抖动剖析(二)
  • LIGO、Virgo第三轮探测告捷,同时探测到一对黑洞合并产生的引力波事件 ...
  • python最赚钱的4个方向,你最心动的是哪个?
  • ​软考-高级-系统架构设计师教程(清华第2版)【第9章 软件可靠性基础知识(P320~344)-思维导图】​
  • ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
  • #pragma multi_compile #pragma shader_feature
  • #pragma once与条件编译
  • (9)STL算法之逆转旋转
  • (env: Windows,mp,1.06.2308310; lib: 3.2.4) uniapp微信小程序
  • (ros//EnvironmentVariables)ros环境变量
  • (附源码)ssm考试题库管理系统 毕业设计 069043
  • (接口自动化)Python3操作MySQL数据库
  • (六)vue-router+UI组件库
  • (学习日记)2024.01.19
  • (原創) 如何解决make kernel时『clock skew detected』的warning? (OS) (Linux)
  • (转)如何上传第三方jar包至Maven私服让maven项目可以使用第三方jar包
  • .NET Core 实现 Redis 批量查询指定格式的Key
  • .Net FrameWork总结
  • .net 发送邮件