結果
問題 | No.334 門松ゲーム |
ユーザー | fine |
提出日時 | 2016-01-16 21:55:41 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 156 ms / 2,000 ms |
コード長 | 1,147 bytes |
コンパイル時間 | 68 ms |
コンパイル使用メモリ | 11,972 KB |
実行使用メモリ | 16,336 KB |
最終ジャッジ日時 | 2023-10-20 00:22:43 |
合計ジャッジ時間 | 2,796 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 92 ms
16,084 KB |
testcase_01 | AC | 90 ms
16,084 KB |
testcase_02 | AC | 145 ms
16,300 KB |
testcase_03 | AC | 94 ms
16,084 KB |
testcase_04 | AC | 91 ms
16,084 KB |
testcase_05 | AC | 94 ms
16,084 KB |
testcase_06 | AC | 107 ms
16,292 KB |
testcase_07 | AC | 124 ms
16,300 KB |
testcase_08 | AC | 104 ms
16,300 KB |
testcase_09 | AC | 110 ms
16,300 KB |
testcase_10 | AC | 156 ms
16,300 KB |
testcase_11 | AC | 115 ms
16,300 KB |
testcase_12 | AC | 96 ms
16,276 KB |
testcase_13 | AC | 92 ms
16,084 KB |
testcase_14 | AC | 103 ms
16,336 KB |
testcase_15 | AC | 105 ms
16,272 KB |
コンパイルメッセージ
Main.rb:47: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:56: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
def kadomatsu original,index tmp = [] 3.times{|i| tmp.push(original[index[i]]) } if tmp.uniq != tmp || tmp.minmax == [tmp[0],tmp[2]].sort return false else return true end end def solution kado,rest,count tmp = rest.combination(3).to_a.select{|a|kadomatsu(kado,a)} flag = count % 2 if tmp.empty? if flag == 0 return false else return true end else tmp.each{|w| if flag == 0 if solution(kado,rest - w,count + 1) return true end else unless solution(kado,rest - w,count + 1) return false end end } if flag == 0 return false else return true end end end n = gets.to_i k = gets.split.map(&:to_i) range = [*0..n-1] kado = range.combination(3).to_a.select{|a|kadomatsu(k,a)} if kado.empty? puts -1 exit end kado.each{|v| if solution(k,range - v,1) puts v.join(' ') exit end } puts -1