結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー cielciel
提出日時 2017-04-24 00:31:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 447 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 11,344 KB
実行使用メモリ 15,904 KB
最終ジャッジ日時 2023-09-29 16:13:09
合計ジャッジ時間 8,144 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,220 KB
testcase_01 AC 77 ms
15,024 KB
testcase_02 AC 76 ms
14,984 KB
testcase_03 AC 76 ms
15,212 KB
testcase_04 AC 435 ms
15,796 KB
testcase_05 AC 76 ms
15,176 KB
testcase_06 AC 436 ms
15,752 KB
testcase_07 AC 442 ms
15,904 KB
testcase_08 AC 435 ms
15,808 KB
testcase_09 AC 436 ms
15,772 KB
testcase_10 AC 77 ms
15,276 KB
testcase_11 AC 127 ms
15,836 KB
testcase_12 AC 76 ms
15,220 KB
testcase_13 AC 90 ms
15,816 KB
testcase_14 AC 77 ms
15,216 KB
testcase_15 AC 79 ms
15,156 KB
testcase_16 AC 78 ms
15,216 KB
testcase_17 AC 81 ms
15,196 KB
testcase_18 AC 439 ms
15,684 KB
testcase_19 AC 440 ms
15,880 KB
testcase_20 AC 437 ms
15,832 KB
testcase_21 AC 440 ms
15,784 KB
testcase_22 AC 438 ms
15,716 KB
testcase_23 AC 447 ms
15,816 KB
testcase_24 AC 440 ms
15,872 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||(!a.empty?&&a[-1]==0) ? 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