Problem Description
Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall.
A blockhouse is a small castle that has four openings through which to shoot. The four openings are facing North, East, South, and West, respectively. There will be one machine gun shooting through each opening.
Here we assume that a bullet is so powerful that it can run across any distance and destroy a blockhouse on its way. On the other hand, a wall is so strongly built that can stop the bullets.
The goal is to place as many blockhouses in a city as possible so that no two can destroy each other. A configuration of
该问题要求编写程序,根据城市地图(最多4x4大小,包含墙壁),计算可以放置多少个炮塔,使得它们彼此不会互相射击。合法配置意味着炮塔不能在同一行或同一列,除非之间至少有一堵墙。给定的输入包括地图描述,以0结尾。输出是每张地图上最大可放置的炮塔数。
订阅专栏 解锁全文
257

被折叠的 条评论
为什么被折叠?



