火力网
来源:互联网 发布:淘宝短网址恢复 编辑:程序博客网 时间:2024/04/27 15:23
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 blockhouses is legal provided that no two blockhouses are on the same horizontal row or vertical column in a map unless there is at least one wall separating them. In this problem we will consider small square cities (at most 4x4) that contain walls through which bullets cannot run through.
The following image shows five pictures of the same board. The first picture is the empty board, the second and third pictures show legal configurations, and the fourth and fifth pictures show illegal configurations. For this board, the maximum number of blockhouses in a legal configuration is 5; the second picture shows one way to do it, but there are several other ways.
Your task is to write a program that, given a description of a map, calculates the maximum number of blockhouses that can be placed in the city in a legal configuration.
The input file contains one or more map descriptions, followed by a line containing the number 0 that signals the end of the file. Each map description begins with a line containing a positive integer n that is the size of the city; n will be at most 4. The next n lines each describe one row of the map, with a '.' indicating an open space and an uppercase 'X' indicating a wall. There are no spaces in the input file.
For each test case, output one line containing the maximum number of blockhouses that can be placed in the city in a legal configuration.
这是ZJO的第二道题目,输入地图,方框是墙,圆圈表示机枪手。找最大数目的摆放个数。
未完。
- 火力网
- 火力网2
- 火力++++++++
- 火力网加强版(difficult)
- 火力网3 (学习总结)
- ZOJ-1002 Fire Net 火力网 题解
- 回溯算法--解火力网问题
- POJ 1829 火力防御网 中文
- SSL P1124 火力网加强版
- zoj1002 FireNet 火力网 C++ 二分图匹配
- 火力网加强版(difficult) SSL_1124 (最大匹配)
- 七月火力
- 吸引火力
- 火力全开
- 基础算法系列总结:回溯算法(解火力网问题)
- 火力电厂生产过程
- 麦子学院火力全开!
- 集中火力(2)
- 学习VC MFC开发必须了解的常用宏和指令
- 算命的科学性
- 删除选中区域的布线的方法
- java中数组列表ArrayList的使用
- Hat’s Words hdu 1247(字典树 map)
- 火力网
- (二)、WCF通道模型
- HTTP 状态代码
- C# WinForm 文件上传下载 (附源码)
- 两种VC操纵EXCEL的方法
- Direct3D中绘制
- linux 常用C函数系列之一
- 存储墙问题
- ASP.NET AJAX入门系列(2):使用ScriptManager控件