結果
問題 | No.334 門松ゲーム |
ユーザー | はむ吉🐹 |
提出日時 | 2016-01-16 13:09:06 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 1,106 bytes |
コンパイル時間 | 1,623 ms |
コンパイル使用メモリ | 12,000 KB |
実行使用メモリ | 10,156 KB |
最終ジャッジ日時 | 2023-10-20 00:03:35 |
合計ジャッジ時間 | 1,568 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,152 KB |
testcase_01 | AC | 28 ms
10,152 KB |
testcase_02 | AC | 46 ms
10,156 KB |
testcase_03 | AC | 29 ms
10,152 KB |
testcase_04 | AC | 28 ms
10,152 KB |
testcase_05 | AC | 29 ms
10,152 KB |
testcase_06 | AC | 36 ms
10,156 KB |
testcase_07 | AC | 39 ms
10,152 KB |
testcase_08 | AC | 33 ms
10,152 KB |
testcase_09 | AC | 35 ms
10,156 KB |
testcase_10 | AC | 61 ms
10,156 KB |
testcase_11 | AC | 39 ms
10,156 KB |
testcase_12 | AC | 29 ms
10,156 KB |
testcase_13 | AC | 29 ms
10,156 KB |
testcase_14 | AC | 35 ms
10,156 KB |
testcase_15 | AC | 33 ms
10,156 KB |
ソースコード
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import collections import itertools IMPOSSIBLE = [-1] def is_kadomatsu(triplet): a, b, c = triplet.values() if a == b or b == c or c == a: return False elif b == max(a, b, c) or b == min(a, b, c): return True else: return False def judge(sequence): if len(sequence) < 3: return IMPOSSIBLE else: for t_triplet in itertools.combinations(sequence.items(), 3): triplet = collections.OrderedDict(t_triplet) if not is_kadomatsu(triplet): continue else: rest_sequence = collections.OrderedDict( p for p in sequence.items() if p[0] not in triplet) result = judge(rest_sequence) if result == IMPOSSIBLE: return triplet else: continue else: return IMPOSSIBLE if __name__ == "__main__": n = int(input()) ks = collections.OrderedDict(enumerate(map(int, input().split()))) print(*judge(ks))