結果

問題 No.334 門松ゲーム
ユーザー FromBooskaFromBooska
提出日時 2023-04-12 12:31:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2024-04-17 01:52:45
合計ジャッジ時間 1,733 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 49 ms
51,840 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# このdfsの実装は難しい

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

def dfs(LIST):
    # LISTの盤面で手番の人が勝つなら勝つ手、負けるなら0を返す
    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(hand) < 3:
                    # ここでreturn 0はダメだ、abcの取り方が悪いだけがある
                    continue
                if max(hand) != hand[1] and min(hand) != hand[1]:
                    new_LIST = []
                    for l in range(L):
                        if l != a and l != b and l != c:
                            new_LIST.append(LIST[l])
                        if dfs(new_LIST) == 0:
                            return (a, b, c)
    # 次の手番が負けるという場合がない=今の手番が負ける
    # 次の手番が負ける場合があればここに来ない
    # ここまで来るということは1回も勝ち手にならなかった=負け
    return 0
                
result = dfs(K)
if result == 0:
    print(-1)
else:
    print(*result)
0