結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー cielciel
提出日時 2017-04-24 00:22:52
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 360 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 11,540 KB
実行使用メモリ 15,992 KB
最終ジャッジ日時 2023-09-29 16:09:04
合計ジャッジ時間 8,156 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,072 KB
testcase_01 AC 79 ms
15,088 KB
testcase_02 WA -
testcase_03 AC 78 ms
14,988 KB
testcase_04 AC 442 ms
15,992 KB
testcase_05 AC 79 ms
15,068 KB
testcase_06 AC 443 ms
15,872 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 439 ms
15,696 KB
testcase_10 AC 77 ms
15,120 KB
testcase_11 WA -
testcase_12 AC 77 ms
15,128 KB
testcase_13 AC 92 ms
15,820 KB
testcase_14 AC 78 ms
15,072 KB
testcase_15 AC 81 ms
15,244 KB
testcase_16 AC 78 ms
15,048 KB
testcase_17 AC 80 ms
15,364 KB
testcase_18 AC 440 ms
15,956 KB
testcase_19 AC 438 ms
15,972 KB
testcase_20 AC 442 ms
15,988 KB
testcase_21 AC 438 ms
15,784 KB
testcase_22 AC 440 ms
15,736 KB
testcase_23 AC 439 ms
15,780 KB
testcase_24 AC 443 ms
15,772 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

M=10**9+7;I=[1,1];*F=I;*R=I
2.upto(99){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;R<<z*R[-1]%M}
def dfs(x,y,a)
	r=x!=W||y!=H ? 0 : F[a.reduce(0,:+)]*a.map{|e|R[e]}.reduce(1,:*)%M
	if a.size<A.size
		dx,dy,n=A[a.size]
		(0..n).each{|i|
			r=(r+dfs(x+dx*i,y+dy*i,a+[i]))%M
		}
	end
	r
end
W,H,K=gets.split.map &:to_i
A=K.times.map{gets.split.map &:to_i}
p dfs(0,0,[])
0