結果

問題 No.334 門松ゲーム
ユーザー finefine
提出日時 2016-01-16 19:09:54
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 11,924 KB
実行使用メモリ 16,392 KB
最終ジャッジ日時 2023-10-20 00:21:33
合計ジャッジ時間 2,602 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
16,104 KB
testcase_01 AC 88 ms
16,104 KB
testcase_02 AC 122 ms
16,312 KB
testcase_03 AC 88 ms
16,104 KB
testcase_04 AC 92 ms
16,104 KB
testcase_05 AC 95 ms
16,104 KB
testcase_06 AC 107 ms
16,292 KB
testcase_07 AC 122 ms
16,296 KB
testcase_08 AC 102 ms
16,300 KB
testcase_09 AC 107 ms
16,316 KB
testcase_10 AC 130 ms
16,340 KB
testcase_11 AC 115 ms
16,308 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 104 ms
16,392 KB
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:36: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:45: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

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)}
    if tmp.empty?
        if count % 2 == 0
            return false
        else
            return true
        end
    else
        tmp.each{|w|
            unless solution(kado,rest - w,count + 1)
                return false
            end
            }
        return true
    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
0