欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1796B.Asterisk-Minor Template
Asterisk-Minor Template
You are given two strings and , consisting of lowercase Latin letters.
A template is string, consisting of lowercase Latin letters and asterisks (character '*'). A template is called asterisk-minor if the number of asterisks in it is less than or equal to the number of letters in it.
A string is said to be matching a template if you can replace each asterisk in with a string of lowercase Latin letters (possibly, an empty string) so that it becomes equal to .
Find an asterisk-minor template such that both and match it, or report that such a template doesn't exist. If there are multiple answers, print any of them.
Input
The first line contains a single integer () — the number of testcases.
The first line of each testcase contains a string (, where is the length of ), consisting of lowercase Latin letters.
The second line contains a string (), consisting of lowercase Latin letters.
Output
For each testcase, output "NO", if there doesn't exist an asterisk-minor template that both and match. Otherwise, print "YES" in the first line and the template in the second line. If there are multiple answers, print any of them.
A template should consist only of lowercase Latin letters and asterisks (character '*'). The number of asterisks should be less than or equal to the number of letters.
Note
In the first testcase, for a template "\*b", you can replace the only asterisk with "aaa" to get "aaab" (which is equal to ) or with "zzz" to get "zzzb" (which is equal to ).
In the third testcase, a template "\*o\*" is not asterisk-minor, as it contains more asterisks than letters. There are no asterisk-minor templates that both and match.
In the fourth testcase, for a template "a\*a\*a\*a", you can replace all asterisks with empty strings to get "aaaa" (which is equal to ) or two of them with "a" and two of them with an empty string to get "aaaaaa" (which is equal to ).
In the fifth testcase, there are no asterisks in a template "abcd", so only "abcd" can match it (which is coincidentally both and ).
Samples
6
aaab
zzzb
codeforces
atcoder
codeforces
tokitlx
aaaa
aaaaaa
abcd
abcd
c
f
YES
*b
YES
*co*
NO
YES
a*a*a*a
YES
abcd
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |