"Topic link"
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_ problem&problem=39
"Original question"
Stacking Boxes
Background
Some Concepts in mathematics and Computer, are simple in one or two dimensions-but become more complex when Extende D to arbitrary dimensions. Consider solving differential equations in several dimensions and analyzing the topology of a n-dimensional. The former is much complicated than it one dimensional relative while the latter bears a remarkable resemblance to I Ts ' Lower-class ' cousin.
The Problem
Consider an n-dimensional ' box ' given by its dimensions. In two Dimensions the box (2,3) might represent a box with length 2 units and width 3 units. In three dimensions the box (4,8,9) can represent a box
(length, width, and height). In 6 dimensions It is, perhaps, unclear what the box (4,5,6,7,8,9) represents; But we can analyze properties of the box such as the sum of its dimensions.
In this problem to analyze a property of a group of n-dimensional boxes. You are are to determine the longest nesting string of boxes, which is a sequence of boxes
such that each box
Nests in box
(
.
A Box D = (
) Nests in a box E = (
) If there is some rearrangement of the
such that then rearranged each dimension are less than the corresponding dimension in box E. This is loosely corresponds to turning box D to if it'll fit in box E. However, since any rearrangement suffices, box D can is contorted, not just turned (= examples below).
For example, the box D = (2,6) Nests in the box E = (7,3) since D can being rearranged as (6,2) So, all dimension is Les s than the corresponding dimension in E. The box D = (9,5,7,3) does not nest in the box E = (2,10,6,8) since no rearrangement of D results into box that satisfies The nesting property, but F = (9,5,7,1) does nest in box e since F can is rearranged as (1,9,5,7) which nests in E.
Formally, we define nesting as follows:box D = (
) nests in box E = (
) If there is a permutation
Of
such that (
) ' Fits ' in (
) i.e., if
For all
.
The Input
The input consists of a series of box sequences. Each box sequence begins with a line consisting of the the number of boxes K in the sequence followed by the Dimensionalit Y of the boxes, n (on the same line.)
This are followed by K lines and one line per box with the N measurements of each box on one line separated by one or mor E spaces. The
Line in the sequence (
) gives the measurements for the
Box.
There May is several box sequences in the input file. Your program should process all of them and determine, for each sequence, which of the k boxes determine the longest nesti ng string and the length of that nesting string (the number of boxes in the string).
This column more highlights: http://www.bianceng.cn/Programming/sjjg/