22254_WoodenBlocks

2022-5-16 18:21| 发布者: Hocassian| 查看: 25| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506243499400-Problem List-采集的数据-后羿采集器.html

Pro.ID

22254

Title

Wooden Blocks

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22254

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1200/400 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    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:
    1. The rectangle must have smooth edges. In other words, the left-most piece must be (piece #1) and the right-most piece must be  (piece #2.)
    2. Adjacent pieces must interlock properly. For example, either piece #4 or piece #5 must appear to the right of piece #1. Similarly, piece #4 can appear to the right of piece #1 or piece #3.
    3. No piece interlocks to the left of piece #1. No piece interlocks to the right of piece #2.
    4. For each piece #1, the rectangle must have a matching piece #2. Similarly, for each piece #5, there must be a matching piece #6.
    For example, the following two examples are valid arrangements:

    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:
    1. The rectangle must have smooth edges. In other words, the left-most piece must be (piece #1) and the right-most piece must be  (piece #2.)
    2. Adjacent pieces must interlock properly. For example, either piece #4 or piece #5 must appear to the right of piece #1. Similarly, piece #4 can appear to the right of piece #1 or piece #3.
    3. No piece interlocks to the left of piece #1. No piece interlocks to the right of piece #2.
    4. For each piece #1, the rectangle must have a matching piece #2. Similarly, for each piece #5, there must be a matching piece #6.
    For example, the following two examples are valid arrangements:

    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

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部