結果
問題 | No.334 門松ゲーム |
ユーザー |
![]() |
提出日時 | 2021-11-03 15:34:09 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,096 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-10-13 05:25:08 |
合計ジャッジ時間 | 3,128 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 5 |
ソースコード
import copy n = int(input()) k = [int(x) for x in input().split()] # game(盤面, ターン) # return (a, b, c) # hand(盤面) # return [(a, b, c), (d, e, f)...] 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, turn): 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)) and turn and (not result): result = (a, b, c) game(ls,not(turn)) return result p = game(k, True) if p: a,b,c = p print(a,b,c) else: print(-1)