問題一覧 > 通常問題

No.3196 Unique Nickname

レベル : / AI推定難易度 : 147 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 156
作問者 : YY-otter / テスター : nauclhlt
お気に入りにしたユーザー ProblemId : 12429 / 自分の提出
問題文最終更新日: 2025-07-11 11:50:33
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 473 第1回 生成AI作問コンテスト (順位表) の他の問題:

Problem Statement

There are $N$ participants, and the $i$-th participant ($1\leq i\leq N$) is given a family name $S_i$ and a given name $T_i$.
A participant $i$ can use as a nickname only those of their family name $S_i$ or given name $T_i$ that do not coincide with the family name or given name of any other participant.
Determine whether each of the $N$ participants has $1$ or more available nicknames.

Input

$N$
$S_1\ T_1$
$S_2\ T_2$
$\dots$
$S_N\ T_N$

  • $1\leq N\leq 100$
  • $S_i,T_i$ are strings consisting only of lowercase English letters
  • $1\leq |S_i|,|T_i|\leq 15$
  • If $i\neq j$, then $(S_i,T_i)\neq (S_j,T_j)$
  • For each individual, $S_i\neq T_i$

Output

Print Yes if everyone has 1 or more available nicknames, and No if there is even one person who does not.
Print a newline at the end.

Sample

Sample 1
Input
3
tanaka taro
sato hanako
tanaka jiro
Output
Yes

  • Person $1$ (tanaka taro): tanaka cannot be used because it coincides with the family name of person $3$. However, taro can be used because it does not coincide with anyone's name. → OK
  • Person $2$ (sato hanako): Neither sato nor hanako coincides with anyone's name. → OK
  • Person $3$ (tanaka jiro): tanaka cannot be used because it coincides with the family name of person $1$. However, jiro can be used because it does not coincide with anyone's name. → OK
Everyone has $1$ or more available nicknames, so the answer is Yes.

Sample 2
Input
3
saito ichiro
saito jiro
suzuki ichiro
Output
No

Person $1$ (saito ichiro): saito coincides with the family name of person $2$, and ichiro coincides with the given name of person $3$. This person does not have any available nickname ($1$ or more are required).
Therefore, the answer is No.

Sample 3
Input
2
suzuki sato
sato suzuki
Output
No

Person $1$ (suzuki sato): suzuki coincides with the given name of person $2$, and sato coincides with the family name of person $2$. There is no available nickname.
Therefore, the answer is No.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。