結果
| 問題 | No.334 門松ゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-19 23:24:47 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
WA
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 700 bytes |
| 記録 | |
| コンパイル時間 | 85 ms |
| コンパイル使用メモリ | 64,576 KB |
| 実行使用メモリ | 59,472 KB |
| 最終ジャッジ日時 | 2026-10-14 23:45:08 |
| 合計ジャッジ時間 | 2,354 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 1 |
ソースコード
from itertools import combinations
N = int(input())
K = list(map(int, input().split()))
dp = [False]*(1<<N)
for S in range((1<<N)-1, -1, -1):
idx = []
for i in range(N):
if not (S>>i)&1:
idx.append(i)
for a, b, c in combinations(idx, 3):
if (K[a]<K[b] and K[b]>K[c]) or (K[a]>K[b] and K[b]<K[c]):
S_ = S
S_ |= 1<<a
S_ |= 1<<b
S_ |= 1<<c
dp[S] |= not dp[S_]
for a, b, c in combinations(range(N), 3):
S = 0
S |= 1<<a
S |= 1<<b
S |= 1<<c
if ((K[a]<K[b] and K[b]>K[c]) or (K[a]>K[b] and K[b]<K[c])) and not dp[S]:
print(a, b, c)
exit()
print(-1)