HBC24043简单的公式[USACO 2015 Dec S]Switching on the Lights题解

柳絮泡泡 算法基础篇 65 0
不断提升技能,才能在职场中立于不败之地!全网最全C++题库,助您成为编程领域的佼佼者。
Farmer John has recently built an enormous barn consisting of anN×NN×Ngrid of rooms , numbered from(1,1)(1,1)up to(N,N)(N,N). Being somewhat afraid of the dark, Bessie the cow wants to turn on the lights in as many rooms as possible. Bessie starts in room(1,1)(1,1), the only room that is initially lit. In some rooms, she will find light switches that she can use to toggle the lights in other rooms; for example there might be a switch in room(1,1)(1,1)that toggles the lights in room(1,2)(1,2). Bessie can only travel through lit rooms, and she can only move from a room(x,y)(x,y)to its four adjacent neighbors,,and. Please determine the maximum number of rooms Bessie can illuminate.

Farmer John has recently built an enormous barn consisting of an N×NN×N grid of rooms (2≤N≤1002≤N≤100), numbered from (1,1)(1,1) up to (N,N)(N,N). Being somewhat afraid of the dark, Bessie the cow wants to turn on the lights in as many rooms as possible. Bessie starts in room (1,1)(1,1), the only room that is initially lit. In some rooms, she will find light switches that she can use to toggle the lights in other rooms; for example there might be a switch in room (1,1)(1,1) that toggles the lights in room (1,2)(1,2). Bessie can only travel through lit rooms, and she can only move from a room (x,y)(x,y) to its four adjacent neighbors (x−1,y)(x−1,y), (x+1,y)(x+1,y), (x,y−1)(x,y−1)and (x,y+1)(x,y+1) (or possibly fewer neighbors if this room is on the boundary of the grid). Please determine the maximum number of rooms Bessie can illuminate.

HBC24043简单的公式[USACO 2015 Dec S]Switching on the Lights题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC24043简单的公式[USACO 2015 Dec S]Switching on the Lights题解