結果

問題 No.334 門松ゲーム
ユーザー HachimoriHachimori
提出日時 2016-03-06 12:52:38
言語 Python2
(2.7.18)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,067 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 7,124 KB
実行使用メモリ 6,416 KB
最終ジャッジ日時 2023-10-24 20:05:36
合計ジャッジ時間 943 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,416 KB
testcase_01 AC 10 ms
6,416 KB
testcase_02 AC 18 ms
6,416 KB
testcase_03 AC 11 ms
6,416 KB
testcase_04 AC 10 ms
6,416 KB
testcase_05 AC 10 ms
6,416 KB
testcase_06 AC 14 ms
6,416 KB
testcase_07 AC 15 ms
6,416 KB
testcase_08 AC 12 ms
6,416 KB
testcase_09 AC 12 ms
6,416 KB
testcase_10 AC 24 ms
6,416 KB
testcase_11 AC 13 ms
6,416 KB
testcase_12 AC 11 ms
6,416 KB
testcase_13 AC 10 ms
6,416 KB
testcase_14 AC 12 ms
6,416 KB
testcase_15 AC 11 ms
6,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8

def read():
    raw_input()
    return map(int, raw_input().split())


def isKadomatsu(A, B, C):
    return B > A > C or B > C > A or A > C > B or C > A > B


def rec(vList, used):
    
    for i in range(len(vList)):
        if used[i]:
            continue
        
        for j in range(i + 1, len(vList)):
            if used[j]:
                continue
            
            for k in range(j + 1, len(vList)):
                if used[k]:
                    continue
                
                if not isKadomatsu(vList[i], vList[j], vList[k]):
                    continue
                
                used[i] = used[j] = used[k] = True
                
                opp = rec(vList, used)
                
                used[i] = used[j] = used[k] = False
                
                if opp == [-1]:
                    return [i, j, k]
                
    return [-1]


def work(vList):
    print " ".join(map(str, rec(vList, [False for v in vList])))


if __name__ == "__main__":
    work(read())
0