Marathon Match 21 - Marathon Match 21

Key Information

The challenge is finished.

Challenge Overview

Problem Statement


You are packing shapes into a box, and wish to pack as many as possible. Each shape must be packed one at a time, in the order they are received, and cannot be moved once packed. Shapes may not overlap, and may not extend beyond the bounds of the box.

Your goal is to pack the box as fully as possible, leaving as little empty space as possible. For each call of your placeTile method, return a int[] with three elements, x, y, and r, indicating the location and rotation of the shape to place. Placing a piece at (x,y) places the upper left corner of its bounding box at that location. Return an empty int[] when you are no longer able to pack an item into the box. Both the box and item parameters are such that the first character of the first string is the upper-left (0,0) of the box/piece and the last character of the last string is the bottom right. Each 'X' character indicates part of a piece, or a location in the box that is already filled, while each '.' character represents an empty location.

The width and height of the box are chosen between 10 and 100, uniformly at random. Each shape to place is a polyomino of size 4 or 5 that can be rotated in 90 degree increments, but not flipped over. There are 7 such pieces of size 4, and 18 of size 5. Each of the 25 total pieces is equally likely to be chosen next. An example of rotating a piece is shown below:

XXX     XX      X..     .X
..X     X.      XXX     .X
        X.              XX
r = 0   r = 1   r = 2   r = 3

Your raw score for each test case will be the amount of unused space in the box. (If your solution produces an error, makes an invalid move, etc, then all spaces are considered unused.) The total unused spaces over all cases will be summed for each submission. Your final score will be 1000 * best_sum / your_sum.

A visualization tool is available to aid you in development.


Parameters:String[], String[]
Method signature:int[] placeTile(String[] box, String[] item)
(be sure your method is public)


-Runtime limit is 30 seconds per test case.
-Memory limit is 1024 MB.


Returns: "width = 10
height = 10"
Returns: "width = 20
height = 20"
Returns: "width = 40
height = 40"
Returns: "width = 70
height = 70"
Returns: "width = 100
height = 100"
Returns: "width = 14
height = 81"
Returns: "width = 13
height = 22"
Returns: "width = 11
height = 54"
Returns: "width = 10
height = 49"
Returns: "width = 12
height = 81"

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2020, TopCoder, Inc. All rights reserved.