結果
問題 | No.334 門松ゲーム |
ユーザー |
![]() |
提出日時 | 2024-07-16 23:46:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 321 ms / 2,000 ms |
コード長 | 812 bytes |
コンパイル時間 | 1,279 ms |
コンパイル使用メモリ | 81,552 KB |
実行使用メモリ | 76,328 KB |
最終ジャッジ日時 | 2024-07-16 23:46:05 |
合計ジャッジ時間 | 3,117 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
from itertools import combinations def is_kadomatu(a: int, b: int, c: int) -> bool: if a == b or b == c or c == a: return False if a < b < c: return False if a > b > c: return False return True def f(turn, used) -> bool: res = False for a, b, c in combinations(range(N), 3): if used[a] or used[b] or used[c]: continue if not is_kadomatu(A[a], A[b], A[c]): continue used[a] = used[b] = used[c] = turn res |= not f(turn+1, used) if res and turn == 1: return True used[a] = used[b] = used[c] = 0 return res N = int(input()) A = list(map(int, input().split())) used = [0] * N iswin = f(1, used) if not iswin: print(-1) exit() ans = [] for i in range(N): if used[i] == 1: ans.append(i) print(*ans)