103030: [Atcoder]ABC303 A - Similar String

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:13 Solved:0

Description

Score : $100$ points

Problem Statement

Two characters $x$ and $y$ are called similar characters if and only if one of the following conditions is satisfied:

  • $x$ and $y$ are the same character.
  • One of $x$ and $y$ is 1 and the other is l.
  • One of $x$ and $y$ is 0 and the other is o.

Two strings $S$ and $T$, each of length $N$, are called similar strings if and only if:

  • for all $i\ (1\leq i\leq N)$, the $i$-th character of $S$ and the $i$-th character of $T$ are similar characters.

Given two length-$N$ strings $S$ and $T$ consisting of lowercase English letters and digits, determine if $S$ and $T$ are similar strings.

Constraints

  • $N$ is an integer between $1$ and $100$.
  • Each of $S$ and $T$ is a string of length $N$ consisting of lowercase English letters and digits.

Input

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

$N$
$S$
$T$

Output

Print Yes if $S$ and $T$ are similar strings, and No otherwise.


Sample Input 1

3
l0w
1ow

Sample Output 1

Yes

The $1$-st character of $S$ is l, and the $1$-st character of $T$ is 1. These are similar characters.

The $2$-nd character of $S$ is 0, and the $2$-nd character of $T$ is o. These are similar characters.

The $3$-rd character of $S$ is w, and the $3$-rd character of $T$ is w. These are similar characters.

Thus, $S$ and $T$ are similar strings.


Sample Input 2

3
abc
arc

Sample Output 2

No

The $2$-nd character of $S$ is b, and the $2$-nd character of $T$ is r. These are not similar characters.

Thus, $S$ and $T$ are not similar strings.


Sample Input 3

4
nok0
n0ko

Sample Output 3

Yes

Input

题意翻译

### 题目描述 定义字符 $x$ 和 $y$ 相似,当且仅当 $x$ 和 $y$ 满足以下三个条件之一: - $x$ 和 $y$ 是相同的字符。 - $x$ 和 $y$ 中一个是 `1`,一个是 `l`。 - $x$ 和 $y$ 中一个是 `0`,一个是 `o`。 定义长度为 $n$ 的字符串 $s$ 和 $t$ 相似,当且仅当 $s$ 和 $t$ 满足以下条件: - 对于所有 $1\le i\le n$,都满足 $s_i$ 和 $t_i$ 相似。 ### 输入格式 第一行输入一个整数 $n~(1\le n\le 100)$,代表字符串长度。 第二行和第三行输入两个长度为 $n$ 的两个字符串 $s$ 和 $t$,且仅由小写字母和数字组成。 ### 输出格式 若字符串 $s$ 和 $t$ 相似,输出 `Yes`,否则输出 `No`。 Translated by [Special_Tony](https://www.luogu.com.cn/user/571147) .

Output

分数:100分

问题描述

如果满足以下条件之一,两个字符$x$和$y$称为相似字符:

  • $x$和$y$是相同的字符。
  • $x$和$y$中一个是1,另一个是l
  • $x$和$y$中一个是0,另一个是o

如果且仅当以下条件成立,则称长度为$N$的两个字符串$S$和$T$为相似字符串:

  • 对于所有的$i\ (1\leq i\leq N)$,$S$的第$i$个字符和$T$的第$i$个字符是相似字符。

给定两个长度为$N$的字符串$S$和$T$,由小写英文字母和数字组成,确定$S$和$T$是否为相似字符串。

约束条件

  • $N$是一个介于$1$和$100$之间的整数。
  • $S$和$T$都是长度为$N$的字符串,由小写英文字母和数字组成。

输入

输入从标准输入中给出,格式如下:

$N$
$S$
$T$

输出

如果$S$和$T$是相似字符串,则打印Yes,否则打印No


样例输入1

3
l0w
1ow

样例输出1

Yes

$S$的第$1$个字符是l,$T$的第$1$个字符是1。这两个字符是相似字符。

$S$的第$2$个字符是0,$T$的第$2$个字符是o。这两个字符是相似字符。

$S$的第$3$个字符是w,$T$的第$3$个字符是w。这两个字符是相似字符。

因此,$S$和$T$是相似字符串。


样例输入2

3
abc
arc

样例输出2

No

$S$的第$2$个字符是b,$T$的第$2$个字符是r。这两个字符不是相似字符。

因此,$S$和$T$不是相似字符串。


样例输入3

4
nok0
n0ko

样例输出3

Yes

HINT

两个字符串是否相同?o和0、l和1看成是相同的哦!

加入题单

算法标签: