欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1023A.Single Wildcard Pattern Matching
Single Wildcard Pattern Matching
You are given two strings and . The string consists of lowercase Latin letters and at most one wildcard character '\*', the string consists only of lowercase Latin letters. The length of the string equals , the length of the string equals .
The wildcard character '\*' in the string (if any) can be replaced with an arbitrary sequence (possibly empty) of lowercase Latin letters. No other character of can be replaced with anything. If it is possible to replace a wildcard character '\*' in to obtain a string , then the string matches the pattern .
For example, if "aba\*aba" then the following strings match it "abaaba", "abacaba" and "abazzzaba", but the following strings do not match: "ababa", "abcaaba", "codeforces", "aba1aba", "aba?aba".
If the given string matches the given string , print "YES", otherwise print "NO".
Input
The first line contains two integers and () — the length of the string and the length of the string , respectively.
The second line contains string of length , which consists of lowercase Latin letters and at most one wildcard character '\*'.
The third line contains string of length , which consists only of lowercase Latin letters.
Output
Print "YES" (without quotes), if you can obtain the string from the string . Otherwise print "NO" (without quotes).
Note
In the first example a wildcard character '\*' can be replaced with a string "force". So the string after this replacement is "codeforces" and the answer is "YES".
In the second example a wildcard character '\*' can be replaced with an empty string. So the string after this replacement is "vkcup" and the answer is "YES".
There is no wildcard character '\*' in the third example and the strings "v" and "k" are different so the answer is "NO".
In the fourth example there is no such replacement of a wildcard character '\*' that you can obtain the string so the answer is "NO".
Samples
6 10
code*s
codeforces
YES
6 5
vk*cup
vkcup
YES
1 1
v
k
NO
9 6
gfgf*gfgf
gfgfgf
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |