結果

問題 No.334 門松ゲーム
コンテスト
ユーザー pluto77
提出日時 2018-07-27 12:17:11
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 31 ms / 2,000 ms
+ 656µs
コード長 478 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 50 ms
コンパイル使用メモリ 14,720 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2026-10-14 23:32:23
合計ジャッジ時間 1,835 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#yuki334
import itertools


def iskd(t,l):
    a,b,c = [l[i] for i in t]
    if a==b or b==c or a==c:
        return False
    return max(a,b,c)==b or min(a,b,c) == b
  

def solve(n,l):
 if n<3:
  return (-1, )
 for t in itertools.combinations(range(n),3):
  if not iskd(t,l):
   continue
  ks=[k for i,k in enumerate(l) if i not in t]
  res=solve(n-3,ks)
  if res==(-1, ):
   return t
 return (-1, )

n=int(input())
l=list(map(int,input().split()))        
print(*solve(n,l))
0