JIJ 编程竞赛 2026(第 476 场 AtCoder Beginner Contest)
B
通配符
Wild Card
AtCoder
⌀ 0
原题
←C →

通配符AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

$S$ is a string of length $N$ consisting of lowercase English letters. $T$ is a string of length $N$ consisting of lowercase English letters and *. We say that $S$ matches $T$ if and only if $T$ can be made equal to $S$ by replacing each * in $T$ with some lowercase English letter. Determine whether $S$ matches $T$.

$S$ 是一个长度为 $N$、由小写英文字母组成的字符串。 $T$ 是一个长度为 $N$、由小写英文字母和 * 组成的字符串。 当且仅当将 $T$ 中的每个 * 替换为某个小写英文字母后,可以使 $T$ 与 $S$ 相等时,我们称 $S$ 与 $T$ 匹配。 请判断 $S$ 与 $T$ 是否匹配。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \leq N \leq 100$
  • $S$ is a string of length $N$ consisting of lowercase English letters.
  • $T$ is a string of length $N$ consisting of lowercase English letters and *.
  • $1 \leq N \leq 100$
  • $S$ 是一个长度为 $N$、由小写英文字母组成的字符串。
  • $T$ 是一个长度为 $N$、由小写英文字母和 * 组成的字符串。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

N
S
T

N
S
T
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output Yes if $S$ matches $T$, and No otherwise, in one line.

如果 $S$ 与 $T$ 匹配,输出 Yes;否则输出 No。请在一行中输出。AI (CI翻译)

样例

Input #1
8
chokudai
**o*u*ai
Output #1
Yes
By replacing the first, second, fourth, and sixth characters of $T$, which are `*`, with `c`, `h`, `k`, and `d`, respectively, $T$ can be made equal to $S$.
Input #2
5
snuke
snake
Output #2
No
Input #3
5
yiwiy
*****
Output #3
Yes
题目信息
题号
abc476_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。