Nested Crates ------ ------ Given the length, width, and depth of each of a set of crates, determine the maximum number that can be nested inside each other. Because the foam used to pack crates inside each other consists of rectilinear blocks, a nested crate must have sides parallel to its containing crate. Thus a crate fits in another if and only each dimension of the smaller is less than the corresponding dimension of the larger (where crates can be rotated, of course). Input ----- For each of several test cases, first one line con- taining just the test case name, and then one line containing just the number N of crates, and then N lines each containing H W D where H, W, and D are the height, width, and depth of one crate. All numbers are integers. Some of the crates are very small and some very large; a bit strange, but true. 2 <= N <= 100 1 <= H,W,D <= 1,000 Input ends with an end of file. Output ------ For each test case, first a copy of the test case name line from the input, and then one line containing just the maximum number of crates that can be nested inside each other. Note that the largest crate in a set of nested crates is counted, so if no two crates nest, the answer is `1'. Sample Input ------ ----- -- SAMPLE 1 -- 2 1 1 1 4 6 1 -- SAMPLE 2 -- 4 1 1 1 2 2 2 3 3 3 1 2 3 -- SAMPLE 3 -- 5 2 2 2 3 3 3 4 4 4 2 2 3 1 1 2 Sample Output ------ ------ -- SAMPLE 1 -- 1 -- SAMPLE 2 -- 3 -- SAMPLE 3 -- 3 Tips ---- Input consists of lines read from the standard input. Input ends when an end-of-file is read from the standard input. Output consists of lines written to the standard output. For example input/output code see ~/demos/solutions/summer/summer.EXT where EXT is c, cc, or java. You can add debugging code that prints which crates can be nested inside which other crates. The output of running `make debug' on the judge's solution is: -- SAMPLE 1 -- (1,1,1) 1 -- SAMPLE 2 -- (1,1,1)<(2,2,2) (1,1,1)<(3,3,3) (2,2,2)<(3,3,3) (1,1,1)<(2,2,2)<(3,3,3) 3 -- SAMPLE 3 -- (2,2,2)<(3,3,3) (2,2,2)<(4,4,4) (3,3,3)<(4,4,4) (2,2,3)<(4,4,4) (1,1,2)<(3,3,3) (1,1,2)<(4,4,4) (1,1,2)<(2,2,3) (1,1,2)<(3,3,3)<(4,4,4) 3 Here the judge, being a bit of a debugging fanatic, has taken the trouble to compute and output one of the possible maximum nestings, which is output on the line just before the maximum nesting length. File: crates.txt Author: Shai Simonson with minor revisions by Bob Walton Date: Sat Oct 5 06:10:25 EDT 2013 The authors have placed this file in the public domain; they make no warranty and accept no liability for this file. RCS Info (may not be true date or author): $Author: walton $ $Date: 2013/10/05 12:05:21 $ $RCSfile: crates.txt,v $ $Revision: 1.3 $