Pro.ID22254 TitleWooden Blocks Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22254 AC0 Submit0 Ratio- 时间&空间限制描述Blocks is a game where you’re given wooden pieces that come in eight shapes as shown below:
The objective of the game is to assemble the widest rectangle that can be made of a subset of the given pieces with the following conditions:
Whereas the following three are not:
A computer company is interested in building a Blocks video game and has hired you to write a program that determines if a given pieces’ arrangement is valid according to the rules above, or not. 输入Your program will be tested on one or more test cases. Each test case is specified on a separate input line. Each piece is specified using the digit associated with it as in the previous figure. An arrangement is specified by listing its digits with no spaces between the digits. Each arrangement will have at least one piece, but no more than 10,000 pieces. The last line in the input file will have a single 0. That line is not part of the test cases. 输出Description Blocks is a game where you’re given wooden pieces that come in eight shapes as shown below:
The objective of the game is to assemble the widest rectangle that can be made of a subset of the given pieces with the following conditions:
Whereas the following three are not:
A computer company is interested in building a Blocks video game and has hired you to write a program that determines if a given pieces’ arrangement is valid according to the rules above, or not. Input Your program will be tested on one or more test cases. Each test case is specified on a separate input line. Each piece is specified using the digit associated with it as in the previous figure. An arrangement is specified by listing its digits with no spaces between the digits. Each arrangement will have at least one piece, but no more than 10,000 pieces. The last line in the input file will have a single 0. That line is not part of the test cases. Output For each test case, output the result on a single line using the following format: k. result Where k is the test case number (starting at 1,) and result is "VALID" if the arrangement is valid, or "NOT" if it’s not. Sample Input 142 1587862 132 143 0 Sample Output 1. VALID 2. VALID 3. NOT 4. NOT Source 样例输入142 1587862 132 143 0 样例输出1. VALID 2. VALID 3. NOT 4. NOT 作者 |