結果

問題 No.3171 Color Restoration
ユーザー t98slider
提出日時 2025-02-21 01:35:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2025-06-06 20:50:07
合計ジャッジ時間 1,947 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

table = [
    ["gray","brown","green","cyan","blue","yellow","orange","red"],
    ["gray","green","blue","yellow","red"],
    ["gray","green","cyan","blue","violet","orange","red"]
]

# 入力を受け取る
S = input().split()

# ソートする
S.sort()

# 何通りあるかのカウンター
cnt = 0

# 順列全探索 (重複を除く)
for tmp_S in set(itertools.permutations(S)):
    # 条件を満たしているかのフラグ
    is_satisfied = True

    for i in range(3):
        # table[i] に該当するサイト内で S[i] に該当する色があるかを調べる
        if not tmp_S[i] in table[i]:
            # 該当する色がなかった場合の処理
            is_satisfied = False
            break
    
    # すべてのサイトで条件を満たしていた場合カウンタをインクリメント
    cnt += is_satisfied

# 答えを出力
print('Yes' if cnt == 1 else 'No')
0