結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-01-16 13:09:06 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 1,106 bytes |
| コンパイル時間 | 78 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-09-19 19:56:07 |
| 合計ジャッジ時間 | 1,252 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#!/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))
はむ吉🐹