The Parking Lot ProblemLets assume that we have a parking lot with fixed dimension, and there is a large variety of cars, busses,motorcycles and various other vehicles that need to be parked on it for long term. In the long term, wedo not care where the individual vehicles are, and if they are accessible or not, all that we care about isto fit all of the vehicles on the lot.1. IntroductionGiven a matrix sizes 𝑃 ∈ 𝑁𝐿×𝑊 which shows, the position of the individual cars on the lot. Let us alsohave a set of vehicles V= {(𝑙𝑖, 𝑤𝑖)}𝑖=1𝑁 , where li is the length of vehicle i., and wi is the width of the vehiclei. For example, on a 5x7 sized parking lot, and set of vehicles:V = {(4,2),(3,2),(1,2),(2,5),(2,2),(2,1),(3,1)}A possible arrangement of vehicles can be placed as follows:1 1 1 1 4 4 61 1 1 1 4 4 62 2 3 3 4 4 72 2 5 5 4 4 72 2 5 5 4 4 7Our goal is to fit all object in O into the P matrix. You can rotate vehicles 90 degrees, in fact, in mostcases it will be necessary. The problem can easily be demonstrated to be NP hard, yet there still areefficient algorithms that can find a solution reasonably quickly even on large problems.2. AssignmentImplement the filling up of the parking lot in Java or Python. The algorithm can be chosen freely, butyou are not allowed to use any code that you yourself have not written.2.1. JavaThe code must contain a Main class, and within this, a main() function. It will receive all inputs on the代写algorithms、Python编程设计调试、代做Jastandard input, and should output the solution to the standard output. Upload the zipped source codefiles of your application to the BME MIT HomeWork portal.2.2. PythonThe code must be a single python file, that will be run and receives all inputs onto the standard input,and it should write the solution to the standard output. Upload the zipped single python file to the BMEMIT Homework portal.P=2.3. InputsThe input is multiple lines of text, with the individual elements being tab separated. The first linecontains the length and width of the parking lot. The second line contains the number of vehicles. Eachsubsequent row contains the length and width of a single vehicle. So for the above example, the inputwould look like this:2.4. OutputOutput the entire P matrix to the standard output, with values on each line separated by tabs. (Acommon mistake is to have extra tabs at the end of the lines, and we will not accept solutions that makethis error).1 1 1 1 4 4 61 1 1 1 4 4 62 2 3 3 4 4 72 2 5 5 4 4 72 2 5 5 4 4 73. EvaluationThe evaluation is performed with problems of increasing difficulty, in which case the size of the parkinglot is increased, as is the number of vehicles. Only solutions that place all vehicles correctly will beaccepted. The final score will be the number of successful tests. If your solution places the vehiclesincorrectly, you will be notified of any errors. You may then edit and resubmit your solution.转自:http://www.3daixie.com/contents/11/3444.html
讲解:algorithms、Python、JavaPython|R
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- The Inner Game of Tennis W Timothy Gallwey Jonathan Cape ...
- 1.更改扫描图片,需要先到官网上传你要扫描的图片,然后得到一个.dat和.xml文件将文件导入到工程;官网http...