作业帮 > 英语 > 作业

英语翻译Suppose that we have a square city with straight streets

来源:学生作业帮 编辑:作业帮 分类:英语作业 时间:2024/05/13 07:22:00
英语翻译
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.Sample input:
else
if(alloc[j]==shooter)
return -1;
}
for(i=0;i
假定我们有一个城市广场直街上.地图是城市的一个广场,董事会与N行和N个栏目,代表每一条街道或一片墙.一个碉堡是一个小城堡,有四个开口通过它拍摄.四是挖掘面临北,东,南,西,分别.会有一个机枪射击通过每个开幕式.这里我们假设一颗子弹是如此强大,它可以穿越任何距离和摧毁一座碉堡 开展起来.在另一方面,一个墙是如此强烈,建成了可以阻挡子弹.其目标是把许多碉堡在一个城市尽可能使没有两个可以摧毁每 其他.一个配置的碉堡,是法律规定的,没有任何两个碉堡都在同一横列或立柱 在地图上,除非至少有一个隔离墙.在这个问题,我们会考虑小城市广场(最多4 × 4 )含有墙壁透过子弹不能运行 通过.以下图像显示图片五的同一局.第一幅是空局,但第二和第三图片法律配置 而第四次和第五次作品展的非法配置.这一局,最多碉堡在法律配置五日; 第二图示做的一个方法,但是还有其他一些方式.你的任务是写一个节目中说,鉴于地描述了一个图,算出最多碉堡可以放置在该市的法律配置.输入文件包含一个或多个地图说明 其次是一条线含有数字0 ,信号结束的档案.每个地图开始,描述了线路含有一个正整数n ,是规模的城市; 氮将大部分4 .未来线上形容每一个连续的地图,与' .'显示一个开放的空间和一个大写的'十大'显示墙.有没有空间的输入文件.每个测试案例,生产一线含有最多碉堡可以放置在该市的法律配置.样例输入: