結果

問題 No.360 増加門松列
ユーザー lloyz
提出日時 2023-10-17 00:18:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 76,468 KB
最終ジャッジ日時 2024-09-16 23:56:30
合計ジャッジ時間 2,701 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations

def check_kadomatsu(A):
    is_kadomatsu = True
    for i in range(3):
        if A[i] == A[(i + 1) % 3]:
            is_kadomatsu = False
    if not (A[0] < A[1] > A[2] or A[0] > A[1] < A[2]):
        is_kadomatsu = False
    return is_kadomatsu

D = list(map(int, input().split()))
for P in permutations(range(7)):
    A = [D[P[i]] for i in range(7)]
    flag = True
    for i in range(5):
        B = A[i:i + 3]
        if not check_kadomatsu(B):
            flag = False
            break
        if B[0] > B[2]:
            flag = False
            break
    if flag:
        print("YES")
        exit()
print("NO")
0