結果

問題 No.334 門松ゲーム
ユーザー nanaenanae
提出日時 2017-02-10 06:48:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 8,360 KB
最終ジャッジ日時 2023-08-27 05:17:18
合計ジャッジ時間 1,825 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,188 KB
testcase_01 AC 16 ms
8,312 KB
testcase_02 AC 21 ms
8,268 KB
testcase_03 AC 18 ms
8,116 KB
testcase_04 AC 17 ms
8,236 KB
testcase_05 AC 17 ms
8,360 KB
testcase_06 AC 19 ms
8,332 KB
testcase_07 AC 20 ms
8,184 KB
testcase_08 AC 18 ms
8,324 KB
testcase_09 AC 17 ms
8,176 KB
testcase_10 AC 24 ms
8,192 KB
testcase_11 AC 18 ms
8,112 KB
testcase_12 AC 17 ms
8,192 KB
testcase_13 AC 17 ms
8,192 KB
testcase_14 AC 18 ms
8,292 KB
testcase_15 AC 19 ms
8,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import combinations

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def is_kadomatu(a):
    return a[0] != a[2] and (a[0] - a[1])*(a[2] - a[1]) > 0

def can_win(N, K):
    for i, j, k in combinations(range(N), 3):
        if is_kadomatu([K[i], K[j], K[k]]):
            K1 = K[:i] + K[i + 1:j] + K[j + 1:k] + K[k + 1:]
            if can_win(N - 3, K1) == (-1,):
                return i, j, k

    return (-1,)

def solve():
    N = int(input())
    K = [int(i) for i in input().split()]

    ans = can_win(N, K)

    print(*ans)

if __name__ == '__main__':
    solve()
0