結果

問題 No.662 スロットマシーン
ユーザー nonokai10nonokai10
提出日時 2018-03-09 23:10:32
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 896 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 30,336 KB
最終ジャッジ日時 2024-04-19 02:06:27
合計ジャッジ時間 5,241 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
17,536 KB
testcase_01 AC 87 ms
12,672 KB
testcase_02 AC 677 ms
20,096 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

scores = {}
5.times do
  str, coin = gets.split
  scores[str] = coin.to_i
end

reels = []
3.times do
  reel = []
  gets.to_i.times do
    reel << gets.chomp
  end
  reels << reel
end

def check(reel1, reel2, reel3)
  sets = []
  (0..2).each do |i|
    sets << reel1[i] if (reel1[i] == reel2[i] && reel2[i] == reel3[i])
  end
  sets << reel1[0] if (reel1[0] == reel2[1] && reel2[1] == reel3[2])
  sets << reel1[2] if (reel1[2] == reel2[1] && reel2[1] == reel3[0])
  sets
end

sum = 0
count = Hash.new(0)
(0..reels[0].size - 1).each do |i|
  (0..reels[1].size - 1).each do |j|
    (0..reels[2].size - 1).each do |k|
      sum += 1
      check(reels[0].rotate(i), reels[1].rotate(j), reels[2].rotate(k)).each do |s|
        count[s] += 1
      end
    end
  end
end

score = 0
count.each do |key, val|
  score += val * scores[key]
end
p score / sum.to_f

scores.each_key do |key|
  p count[key]
end
0