結果

問題 No.3196 Unique Nickname
ユーザー Ziyan Gong
提出日時 2025-07-30 17:56:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-07-30 17:56:33
合計ジャッジ時間 2,374 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

# 入力
N = int(input())
names = []
all_names = []

for _ in range(N):
    s, t = input().split()
    names.append((s, t))
    all_names.append(s)
    all_names.append(t)

# 统计所有姓和名的出现次数
count = Counter(all_names)

# 对每个人检查:是否有至少一个唯一的(即出现1次的)名字
for s, t in names:
    if count[s] > 1 and count[t] > 1:
        print("No")
        break
else:
    print("Yes")


0