| MAIN Home Schedule Registration Rules About Language Prizes RESULTS Problem Set Judge Data Solutions LINKS LSU Computer Science Contest Index HS 2001 HS 2000 ACM Intl PC PC2 | Wherehouse?Sam's last job seemed to be the most boring one yet; he thought nothing could possibly be worse. He was wrong. Ben Mean, the boss at his new job, expects Sam to retrieve boxes from the company's warehouses. This would be fine, if Mr. Mean told Sam just where the boxes were. All Sam gets from Mr. Mean, however, is the number of the box that he has to find. Finding the box requires looking through all of the warehouses belonging to the company. Sam believes that he has found a better way. He wants to write a program that will convert the single number Mr. Mean gives him to the exact warehouse, bay, aisle, row, and column of the box to find. That way he will be able to spend more time doing the important things . . . like playing video games. Description: Help Sam figure out where all of the boxes are. Some jobs will be easier for him because he won't have to worry about some of the location specifiers--his office is right next to Warehouse 1, Bay 1, Aisle 1, Row 1, Column 1 (an amazing coincidence, to be sure), so he doesn't bother with using any specifier that he doesn't really need. You will be told how many specifiers Sam must worry about and how large a range each specifier has. Then you will be given a set of box numbers to translate to their actual location. The order of change, from least-often to most-often, is warehouse, bay, aisle, row, and then column. So when you only have to work with two specifiers, you will be dealing with rows and columns; when you work with four, you will be dealing with bays, aisles, rows, and columns. Because of the cumbersome nature of spelling this all out--Sam is of the Slacker family, after all--he has come up with a shorthand notation for this. The shorthand notation is as follows: [w,b,a,r,c]where w is the warehouse, b is the bay, a is the aisle, r is the row, and c is the column. Any irrelevant specifier is simply omitted. The next example shows this clearly, for a particular job dealing with five rows and two columns: 1 becomes Row 1, Column 1 1 -> [1,1] 2 becomes Row 1, Column 2 2 -> [1,2] 3 becomes Row 2, Column 1 3 -> [2,1] 4 becomes Row 2, Column 2 4 -> [2,2] 5 becomes Row 3, Column 1 5 -> [3,1] 6 becomes Row 3, Column 2 6 -> [3,2] 7 becomes Row 4, Column 1 7 -> [4,1] 8 becomes Row 4, Column 2 8 -> [4,2] 9 becomes Row 5, Column 1 9 -> [5,1] 10 becomes Row 5, Column 2 10 -> [5,2]Any number n, whether it is the number Mr. Mean provides or part of the resulting location, satisfies the statement 1 <= n <= 32000. Input: The first piece of data in the file is the number of different jobs that Sam must complete for Mr. Mean, represented by a non-negative integer. For each job, the first piece of data is a positive integer 1 <= s <= 5 representing the number of specifiers that this job requires dealing with. The next s lines each hold a single positive integer representing the range for that specifier. After that, a single line holds a non-negative integer x representing the number of boxes that Mr. Mean wants Sam to find for that particular job. The next x lines each hold a single positive integer representing one of the numbers that Mr. Mean gave Sam, which you will convert. Output: Before each job, print Job j:where j is the job number, starting from 1. For each box of the job, print n -> [w,b,a,r,c]where n is the box number that Mr. Mean gave Sam, and [w,b,a,r,c] is the shorthand notation of the box location. Remember to omit any irrelevant specifiers.
|