結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー smz_8110smz_8110
提出日時 2017-04-06 11:13:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 478 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 11,352 KB
実行使用メモリ 15,580 KB
最終ジャッジ日時 2023-09-22 23:00:30
合計ジャッジ時間 7,698 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,264 KB
testcase_01 AC 79 ms
15,316 KB
testcase_02 AC 80 ms
15,100 KB
testcase_03 AC 79 ms
15,308 KB
testcase_04 AC 460 ms
15,484 KB
testcase_05 AC 79 ms
15,316 KB
testcase_06 AC 457 ms
15,408 KB
testcase_07 AC 478 ms
15,452 KB
testcase_08 AC 454 ms
15,308 KB
testcase_09 AC 453 ms
15,392 KB
testcase_10 AC 79 ms
15,280 KB
testcase_11 AC 130 ms
15,456 KB
testcase_12 AC 79 ms
15,228 KB
testcase_13 AC 93 ms
15,356 KB
testcase_14 AC 79 ms
15,376 KB
testcase_15 AC 80 ms
15,144 KB
testcase_16 AC 80 ms
15,316 KB
testcase_17 AC 82 ms
15,272 KB
testcase_18 AC 456 ms
15,308 KB
testcase_19 AC 456 ms
15,452 KB
testcase_20 AC 458 ms
15,424 KB
testcase_21 AC 456 ms
15,316 KB
testcase_22 AC 457 ms
15,512 KB
testcase_23 AC 453 ms
15,580 KB
testcase_24 AC 457 ms
15,500 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:11: 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]
  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=GX==0&&GY==0 ? 1 : 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