結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-16 19:09:54 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 881 bytes |
| コンパイル時間 | 80 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 13,312 KB |
| 最終ジャッジ日時 | 2024-09-19 20:14:32 |
| 合計ジャッジ時間 | 2,477 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 3 |
コンパイルメッセージ
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
ソースコード
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