結果

問題 No.334 門松ゲーム
ユーザー eitahoeitaho
提出日時 2016-03-22 00:39:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-04-08 21:36:39
合計ジャッジ時間 1,748 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,112 KB
testcase_01 AC 34 ms
10,112 KB
testcase_02 AC 78 ms
10,112 KB
testcase_03 AC 33 ms
10,112 KB
testcase_04 AC 33 ms
10,112 KB
testcase_05 AC 32 ms
10,112 KB
testcase_06 AC 54 ms
10,112 KB
testcase_07 AC 60 ms
10,112 KB
testcase_08 AC 44 ms
10,112 KB
testcase_09 AC 43 ms
10,112 KB
testcase_10 AC 103 ms
10,112 KB
testcase_11 AC 44 ms
10,112 KB
testcase_12 AC 38 ms
10,112 KB
testcase_13 AC 35 ms
10,112 KB
testcase_14 AC 55 ms
10,112 KB
testcase_15 AC 52 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
used = [0] * N


def valid(a, b, c):
    return len(set([a, b, c])) == 3 and (min(a, b, c) == b or max(a, b, c) == b)


def win(depth):
    for a in range(N):
        for b in range(a + 1, N):
            for c in range(b + 1, N):
                if used[a] or used[b] or used[c] or not valid(A[a], A[b], A[c]):
                    continue
                used[a] = used[b] = used[c] = 1
                w = not win(depth + 1)
                used[a] = used[b] = used[c] = 0
                if w:
                    if depth == 0:
                        print(a, b, c)
                    return 1
    return 0


if not win(0):
    print(-1)
0