1727. Plaque Pack

单点时限: 2.0 sec

内存限制: 256 MB

The Knick Knack Plaque Shack designs plaques of unusual shapes. All the plaques are 1 inch deep, and have a wide variety of shapes, some of which are shown below.

When a plaque comes off the assembly line which will not fit into the box (i.e., it sticks up over the top), Ben closes that box, ships it off, and starts a new box. In the above examples, the height of the boxes is only 12, so it would take two boxes for the first ordering of plaques, but only one for the second. During his free moments between packing plaques, Ben wonders what it would be like if hundreds of computer programmers tried to write code to simulate this monotonous drudgery.

输入格式

Input will consist of multiple test cases. Each test case will start with a line containing three integers n w b, where n indicates the number of plaques to ship, w indicates the width of each plaque, and b indicates the height of each shipping box. These values will lie in the ranges 1 … 100, 1 … 10 and 1 … 100, respectively. Following this line will be n specifications of plaque shapes. Each shape specification starts with a single line containing the integer height h of the plaque (1 ≤ h ≤ 10 and h ≤ b). Following this will be h lines containing w characters each, where each character is either ‘X’ (indicating a part of the plaque ) or ‘.’, indicating empty space. The order in which the plaques appear in the input is the order in which they must be packed in the boxes, and rotating or inverting the plaques is not allowed. The input file will end with the line 0 0 0.

输出格式

For each test case, output a single line containing the maximum height of the plaques in each box, in the order in which they are filled.

样例

Input
3 5 12
5
XXXXX
.XXXX
..XXX
...XX
....X
4
XXX..
..X..
..XXX
..X..
6
X....
X....
X....
X....
X....
XXXXX
3 5 12
6
X....
X....
X....
X....
X....
XXXXX
4
XXX..
..X..
..XXX
..X..
5
XXXXX
.XXXX
..XXX
...XX
....X
0 0 0
Output
9 6
10

1 人解决,1 人已尝试。

1 份提交通过,共有 1 份提交。

8.9 EMB 奖励。

创建: 16 年,10 月前.

修改: 6 年,10 月前.

最后提交: 16 年,9 月前.

来源: East Central North America 2006

题目标签