結果

問題 No.334 門松ゲーム
ユーザー FromBooskaFromBooska
提出日時 2023-04-12 18:51:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,544 KB
最終ジャッジ日時 2024-04-17 05:58:55
合計ジャッジ時間 1,810 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,224 KB
testcase_01 AC 37 ms
51,456 KB
testcase_02 AC 83 ms
75,904 KB
testcase_03 AC 36 ms
51,712 KB
testcase_04 AC 36 ms
52,352 KB
testcase_05 AC 36 ms
51,968 KB
testcase_06 AC 75 ms
76,160 KB
testcase_07 AC 82 ms
76,160 KB
testcase_08 AC 59 ms
67,968 KB
testcase_09 AC 64 ms
70,912 KB
testcase_10 AC 94 ms
76,544 KB
testcase_11 AC 63 ms
72,576 KB
testcase_12 AC 42 ms
59,136 KB
testcase_13 AC 40 ms
57,216 KB
testcase_14 AC 63 ms
70,912 KB
testcase_15 AC 56 ms
66,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 自力練習

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

import sys
sys.setrecursionlimit(10**7)

def dfs(LIST):
    L = len(LIST)
    
    for a in range(L):
        for b in range(a+1, L):
            for c in range(b+1, L):
                hand = [LIST[a], LIST[b], LIST[c]]
                if len(set(hand)) == 3:
                    if max(hand) == hand[1] or min(hand) == hand[1]:
                        new_hand = []
                        for l in range(L):
                            if l != a and l != b and l != c:
                                new_hand.append(LIST[l])
                        if dfs(new_hand) == 0:
                            return (a, b, c)
    return 0

result = dfs(K)             
if result == 0:
    print(-1)
else:
    print(*result)
0