結果
問題 | No.334 門松ゲーム |
ユーザー | FromBooska |
提出日時 | 2024-02-12 18:21:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 1,161 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 76,180 KB |
最終ジャッジ日時 | 2024-02-12 18:21:42 |
合計ジャッジ時間 | 2,156 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
53,460 KB |
testcase_01 | AC | 35 ms
53,460 KB |
testcase_02 | AC | 86 ms
75,936 KB |
testcase_03 | AC | 34 ms
53,460 KB |
testcase_04 | AC | 34 ms
53,460 KB |
testcase_05 | AC | 38 ms
53,460 KB |
testcase_06 | AC | 75 ms
75,792 KB |
testcase_07 | AC | 75 ms
75,776 KB |
testcase_08 | AC | 56 ms
68,312 KB |
testcase_09 | AC | 60 ms
70,624 KB |
testcase_10 | AC | 107 ms
76,180 KB |
testcase_11 | AC | 67 ms
73,604 KB |
testcase_12 | AC | 40 ms
59,568 KB |
testcase_13 | AC | 38 ms
59,056 KB |
testcase_14 | AC | 63 ms
72,720 KB |
testcase_15 | AC | 61 ms
70,512 KB |
ソースコード
# 自分のターンの選択によって次の相手のターンが全て負けに向かえば勝ち # 自分のターンの選択によって次の相手のターンが1つでも勝ちに向かえば負け # LISTの盤面で手番の人が勝つなら勝ち手、負けるなら-1 N = int(input()) K = list(map(int, input().split())) import sys sys.setrecursionlimit(10**7) def dfs(LIST): L = len(LIST) if L < 3: return -1 for a in range(L): for b in range(a+1, L): for c in range(b+1, L): temp = [LIST[a], LIST[b], LIST[c]] if len(set(temp)) != 3: continue if min(temp) != temp[1] and max(temp) != temp[1]: continue remaining = [] for i in range(L): if i != a and i != b and i != c: remaining.append(LIST[i]) if dfs(remaining) == -1: return [a, b, c] # 次の手番が負けるという場合がない=今の手番が負ける return -1 ans = dfs(K) if ans == -1: print(-1) else: print(*ans)