結果

問題 No.3196 Unique Nickname
ユーザー YY-otter
提出日時 2025-06-26 21:44:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 59,920 KB
最終ジャッジ日時 2025-07-10 14:32:23
合計ジャッジ時間 2,923 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N = int(input())
    names = []
    for _ in range(N):
        s, t = input().split()
        names.append((s, t))

    for i in range(N):
        s_i, t_i = names[i]
        
        s_can_use = True
        for j in range(N):
            if i == j: continue
            if s_i == names[j][0] or s_i == names[j][1]:
                s_can_use = False
                break
        
        t_can_use = True
        for j in range(N):
            if i == j: continue
            if t_i == names[j][0] or t_i == names[j][1]:
                t_can_use = False
                break
        
        if not s_can_use and not t_can_use:
            print("No")
            return
            
    print("Yes")

solve()
0