由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 这道题目用 brute force 好慢阿
相关主题
Amazon算法问题请教面试问题请教
一些算法题。问一些coding题
问一道算法题转一些我blog上以前总结题目的日记
Smallest Rectangle Enclosing Black Pixelsfacebook的buffet puzzle
抽空简单说一下昨天的Google Phone Interviewmicrosoft phone interview round 1
onsite遇到的几个面试题An interview problem: largest submatrix
请教一道算法题请教一道电面算法题
问个算法题amazon 1st phone interview
相关话题的讨论汇总
话题: aaaaaaaa话题: cost话题: program
进入JobHunting版参与讨论
1 (共1页)
j*****y
发帖数: 1071
1
是这个网站上的一道 puzzle
http://www.itasoftware.com/careers/puzzle_archive.html
我是通过分别 分割 x 坐标 和 y 坐标,得到更小的 area, 实行 brute force
, 看不出来这么小的区域计算量也很大。
Strawberry Fields
Strawberries are growing in a rectangular field of length and width at most
50. You want to build greenhouses to enclose the strawberries. Greenhouses
are rectangular, axis-aligned with the field (i.e., not diagonal), and may
not overlap. The cost of each greenhouse is $10 plus $1 per unit of area
covered.
Write a program that chooses the best number of greenhouses to build, and
their locations, so as to enclose all the strawberries as cheaply as
possible. Heuristic solutions that may not always produce the lowest
possible cost will be accepted: seek a reasonable tradeoff of efficiency and
optimality.
Your program must read a small integer 1 ≤ N ≤ 10 representing the maximum
number of greenhouses to consider, and a matrix representation of the field
, in which the '@' symbol represents a strawberry. Output must be a copy of
the original matrix with letters used to represent greenhouses, preceded by
the covering's cost. Here is an example input-output pair:
Input
4
..@@@@@...............
..@@@@@@........@@@...
.....@@@@@......@@@...
.......@@@@@@@@@@@@...
.........@@@@@........
.........@@@@@........
Output
90
..AAAAAAAA............
..AAAAAAAA....CCCCC...
..AAAAAAAA....CCCCC...
.......BBBBBBBCCCCC...
.......BBBBBBB........
.......BBBBBBB........
In this example, the solution cost of $90 is computed as (10+8*3) + (10+7*3)
+ (10+5*3).
Run your program on the 9 sample inputs found in this file and report the
total cost of the 9 solutions found by your program, as well as each
individual solution.
1 (共1页)
进入JobHunting版参与讨论
相关主题
amazon 1st phone interview抽空简单说一下昨天的Google Phone Interview
问个算法题6onsite遇到的几个面试题
一个设计题目,大家讨论一下请教一道算法题
Java positions at B&N NYC问个算法题
Amazon算法问题请教面试问题请教
一些算法题。问一些coding题
问一道算法题转一些我blog上以前总结题目的日记
Smallest Rectangle Enclosing Black Pixelsfacebook的buffet puzzle
相关话题的讨论汇总
话题: aaaaaaaa话题: cost话题: program