結果

問題 No.334 門松ゲーム
ユーザー FromBooskaFromBooska
提出日時 2023-03-10 22:34:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 76,052 KB
最終ジャッジ日時 2023-10-18 08:16:35
合計ジャッジ時間 2,173 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,480 KB
testcase_01 AC 39 ms
53,480 KB
testcase_02 AC 111 ms
75,976 KB
testcase_03 AC 39 ms
53,480 KB
testcase_04 AC 38 ms
53,480 KB
testcase_05 AC 39 ms
53,480 KB
testcase_06 AC 81 ms
75,836 KB
testcase_07 AC 88 ms
75,796 KB
testcase_08 AC 62 ms
68,492 KB
testcase_09 AC 69 ms
72,612 KB
testcase_10 AC 100 ms
76,052 KB
testcase_11 AC 67 ms
72,648 KB
testcase_12 AC 45 ms
59,596 KB
testcase_13 AC 42 ms
59,048 KB
testcase_14 AC 67 ms
70,640 KB
testcase_15 AC 58 ms
68,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
K = list(map(int, input().split()))

def dfs(LIST):
    # LISTの盤面で手番の人が勝つなら勝つ手、負けるなら0
    L = len(LIST)
    
    for i in range(L):
        for j in range(i+1, L):
            for k in range(j+1, L):
                hand = [LIST[i], LIST[j], LIST[k]]
                if len(set(hand)) != 3:
                    continue
                if max(hand) == LIST[j] or min(hand) == LIST[j]:
                    new_LIST = []
                    for l in range(L):
                        if l != i and l != j and l != k:
                            new_LIST.append(LIST[l])
                    if dfs(new_LIST) == 0:
                        return [i, j, k]
    return 0
            
result = dfs(K)
if result == 0:
    print(-1)
else:
    print(*result)
0