結果
問題 | No.334 門松ゲーム |
ユーザー |
![]() |
提出日時 | 2021-11-03 16:08:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,321 bytes |
コンパイル時間 | 130 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-10-13 06:06:42 |
合計ジャッジ時間 | 2,168 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 4 |
ソースコード
import copy n = int(input()) k = [int(x) for x in input().split()] def are_kadomatsu(x,y,z): if x == y or y == z or z == x: return False elif x < y < z or x > y > z: return False return True def hand(num_list): num = len(num_list) hand_list = [] for a in range(num): for b in range(a+1, num): for c in range(b+1, num): if are_kadomatsu(num_list[a], num_list[b], num_list[c]): hand_list.append((a, b, c)) return hand_list def game(num_list): result = () if hand(num_list): for (a,b,c) in hand(num_list): ls = copy.copy(num_list) ls.pop(a) ls.pop(b-1) ls.pop(c-2) if not hand(ls): result = (a,b,c) break else: for (a,b,c) in hand(ls): ls2 = copy.copy(ls) ls2.pop(a) ls2.pop(b-1) ls2.pop(c-2) if not hand(ls2): result = () break else: result = game(ls2) return result if p:=game(k): a, b, c = p print(a, b, c) else: print(-1)