22383_Help!

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

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

Pro.ID

22383

Title

Help!

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    MegaFirm Inc. has created a set of patterns to aid its telephone help-desk operators in responding to customers. A pattern is a phrase consisting of words and placeholders. A word is simply a string of letters. A placeholder is a word enclosed in angle brackets (that is < ... >). A phrase matches a pattern if each placeholder in the pattern can be systematically replaced by a word so as to make the pattern and phrase equal. By "systematically replaced" we mean that all placeholders enclosing the same word are replaced by the same word.

    For example, the phrase

       to be or not to be

    matches the pattern

       be  not

    because we can replace by to, by or, and by be.

    Given two patterns, you are to find a phrase that matches both.

    输入

    The first line of input contains n, the number of test cases. Each test case consists of two lines of input; each a pattern. Patterns consist of lowercase words, and placeholders containing lowercase words. No pattern exceeds 100 characters. Words contain at most 16 characters. A single space separates adjacent words and placeholders.

    输出

    Description

    MegaFirm Inc. has created a set of patterns to aid its telephone help-desk operators in responding to customers. A pattern is a phrase consisting of words and placeholders. A word is simply a string of letters. A placeholder is a word enclosed in angle brackets (that is < ... >). A phrase matches a pattern if each placeholder in the pattern can be systematically replaced by a word so as to make the pattern and phrase equal. By "systematically replaced" we mean that all placeholders enclosing the same word are replaced by the same word.

    For example, the phrase

       to be or not to be

    matches the pattern

       be  not

    because we can replace by to, by or, and by be.

    Given two patterns, you are to find a phrase that matches both.

    Input

    The first line of input contains n, the number of test cases. Each test case consists of two lines of input; each a pattern. Patterns consist of lowercase words, and placeholders containing lowercase words. No pattern exceeds 100 characters. Words contain at most 16 characters. A single space separates adjacent words and placeholders.

    Output

    For each test case, output a phrase that matches both patterns. If several phrases match, any will do. If no phrase matches, output a line containing "-" (a single minus sign).

    Sample Input

    3
    how now brown
    now cow
    who are you

    b
    c

    Sample Output

    how now brown cow
    -
    c b

    Source

    样例输入

    3
    how now brown
    now cow
    who are you

    b
    c

    样例输出

    how now brown cow
    -
    c b

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部