結果
問題 | No.334 門松ゲーム |
ユーザー | tookunn_1213 |
提出日時 | 2016-01-15 23:16:00 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 900 bytes |
コンパイル時間 | 46 ms |
コンパイル使用メモリ | 7,076 KB |
実行使用メモリ | 6,420 KB |
最終ジャッジ日時 | 2023-10-19 23:34:27 |
合計ジャッジ時間 | 1,034 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
6,420 KB |
testcase_01 | AC | 11 ms
6,420 KB |
testcase_02 | AC | 31 ms
6,420 KB |
testcase_03 | AC | 11 ms
6,420 KB |
testcase_04 | AC | 12 ms
6,420 KB |
testcase_05 | AC | 12 ms
6,420 KB |
testcase_06 | AC | 19 ms
6,420 KB |
testcase_07 | AC | 24 ms
6,420 KB |
testcase_08 | AC | 16 ms
6,420 KB |
testcase_09 | AC | 18 ms
6,420 KB |
testcase_10 | AC | 44 ms
6,420 KB |
testcase_11 | AC | 20 ms
6,420 KB |
testcase_12 | AC | 13 ms
6,420 KB |
testcase_13 | AC | 13 ms
6,420 KB |
testcase_14 | AC | 18 ms
6,420 KB |
testcase_15 | AC | 15 ms
6,420 KB |
ソースコード
def isKadomatsu(a,b,c): if b > a > c or b > c > a:return True if a > c > b 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 flag = False N = int(raw_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