結果

問題 No.334 門松ゲーム
ユーザー 1235486527
提出日時 2019-12-20 14:08:40
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-08 08:31:39
合計ジャッジ時間 1,785 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_kadomatsu(a, b, c):
    if a == c:
        return False
    if (a - b) * (c - b) <= 0:
        return False
    return True

def can_win(a, kl):
    for k in kl:
        if a & set(k):
            continue
        if can_win(a | set(k), kl):
            return False
    return True

N = int(input())
K = list(map(int, input().split()))
kl = [((i, j, k)) for i in range(N-2) for j in range(i+1, N-1) for k in range(j+1, N) if is_kadomatsu(K[i], K[j], K[k])]
ans = None
for k in kl:
    if can_win(set(k), kl):
        ans = k
        break
if ans:
    print(' '.join(map(str, ans)))
else:
    print(-1)
0