結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー smz_8110smz_8110
提出日時 2017-04-06 11:10:58
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 15,728 KB
最終ジャッジ日時 2023-09-22 23:00:00
合計ジャッジ時間 7,804 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,136 KB
testcase_01 AC 81 ms
15,240 KB
testcase_02 WA -
testcase_03 AC 79 ms
15,236 KB
testcase_04 AC 462 ms
15,536 KB
testcase_05 AC 80 ms
15,284 KB
testcase_06 AC 458 ms
15,628 KB
testcase_07 WA -
testcase_08 AC 461 ms
15,416 KB
testcase_09 AC 462 ms
15,524 KB
testcase_10 AC 80 ms
15,052 KB
testcase_11 WA -
testcase_12 AC 79 ms
15,132 KB
testcase_13 AC 92 ms
15,384 KB
testcase_14 AC 79 ms
15,128 KB
testcase_15 AC 81 ms
15,080 KB
testcase_16 AC 80 ms
14,996 KB
testcase_17 AC 80 ms
15,108 KB
testcase_18 AC 456 ms
15,456 KB
testcase_19 AC 459 ms
15,452 KB
testcase_20 AC 460 ms
15,472 KB
testcase_21 AC 459 ms
15,560 KB
testcase_22 AC 462 ms
15,440 KB
testcase_23 AC 461 ms
15,456 KB
testcase_24 AC 458 ms
15,408 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:13: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

GX,GY,K=gets.split.map &:to_i
a=K.times.map{
  x,y,n=gets.split.map(&:to_i)
  (1..n).map{|i|[x*i,y*i,i,i]}
}
F=->a,i,v,r{
  if i+1<a.size
    F[a,i+1,v,r]
  elsif v[0]==GX&&v[1]==GY
    r<<[1]
  end
  a[i].each{|b|
    x,y,n=b
    w=[v[0]+x,v[1]+y,v[2]+[b[-1]]]
    if w[0]==GX&&w[1]==GY
      r<<w[2]
    end
    if i+1<a.size
      F[a,i+1,w,r]
    end
  }
}
F[a,0,[0,0,[]],r=[]]
c=0
h={}
r.each{|v|
  d=(1..v.inject(:+)).to_a.inject(:*)
  v.each{|w|d/=h[w]||h[w]=(1..w).to_a.inject(:*)}
  c+=d
}
p c%1000000007
0