結果

問題 No.334 門松ゲーム
ユーザー
提出日時 2016-01-16 10:33:55
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 923 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 7,116 KB
実行使用メモリ 6,484 KB
最終ジャッジ日時 2023-10-19 23:58:21
合計ジャッジ時間 1,321 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 11 ms
6,484 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 12 ms
6,484 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 15 ms
6,484 KB
testcase_11 AC 14 ms
6,484 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 12 ms
6,484 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def isKadomatsu(a,b,c):
  if b<a<c or c<a<b:return True
  return False
def dfs(N,K,used):
  ret=False
  for ii in range(N):
    if used[ii]:continue
    for jj in range(ii+1,N):
      if used[jj]:continue
      for kk in range(jj+1,N):
        if used[kk]:continue
        if not isKadomatsu(K[ii],K[jj],K[kk]):continue
        used[ii]=used[jj]=used[kk]=True
        ret=ret or not dfs(N,K,used)
        used[ii]=used[jj]=used[kk]=False
  return ret

def main():
  flag=False
  N=input()
  K=map(int,raw_input().split(" "))
  used=[False for i in range(N)]
  for i in range(N):
    for j in range(i+1,N):
      for k in range(j+1,N):
        if not isKadomatsu(K[i],K[j],K[k]):continue
        used[i]=used[j]=used[k]=True
        if not dfs(N,K,used):
          flag=True
          print i,j,k
          break
        used[i]=used[j]=used[k]=False
      if flag:break
    if flag:break
  if not flag:
    print -1
main()
0