当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1866:Help!

Special Judge 特殊评判
题目描述
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
<foo> be <bar> not <foo> <baf>

because we can replace <foo> by to, <bar> by or, and <baf> 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.
输出解释
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).
输入样例
3
how now brown 
 now  cow
who are you
  
 b
c 
输出样例
how now brown cow
-
c b

源链接: POJ-1866

最后修改于 2020-10-29T06:16:12+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 30000