結果

問題 No.360 増加門松列
ユーザー lam6er
提出日時 2025-03-31 17:31:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 68,440 KB
最終ジャッジ日時 2025-03-31 17:32:03
合計ジャッジ時間 2,100 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

def is_valid(perm):
    for i in range(len(perm) - 2):
        a, b, c = perm[i], perm[i+1], perm[i+2]
        if a == b or b == c or a == c:
            return False
        if a >= c:
            return False
        is_max = b > a and b > c
        is_min = b < a and b < c
        if not (is_max or is_min):
            return False
    return True

D = list(map(int, input().split()))
found = False

# Generate all unique permutations
unique_perms = list(set(itertools.permutations(D)))

for perm in unique_perms:
    if is_valid(perm):
        found = True
        break

print("YES" if found else "NO")
0