結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー TawaraTawara
提出日時 2016-07-14 21:08:36
言語 Python2
(2.7.18)
結果
AC  
実行時間 504 ms / 2,000 ms
コード長 1,040 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 148,864 KB
最終ジャッジ日時 2024-04-23 19:14:42
合計ジャッジ時間 7,695 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,272 KB
testcase_01 AC 10 ms
6,400 KB
testcase_02 AC 10 ms
6,272 KB
testcase_03 AC 9 ms
6,272 KB
testcase_04 AC 420 ms
98,432 KB
testcase_05 AC 10 ms
6,400 KB
testcase_06 AC 486 ms
148,736 KB
testcase_07 AC 437 ms
100,992 KB
testcase_08 AC 495 ms
148,608 KB
testcase_09 AC 504 ms
148,480 KB
testcase_10 AC 10 ms
6,400 KB
testcase_11 AC 178 ms
31,488 KB
testcase_12 AC 10 ms
6,400 KB
testcase_13 AC 147 ms
18,688 KB
testcase_14 AC 11 ms
6,272 KB
testcase_15 AC 19 ms
7,168 KB
testcase_16 AC 10 ms
6,400 KB
testcase_17 AC 17 ms
7,168 KB
testcase_18 AC 503 ms
148,608 KB
testcase_19 AC 496 ms
148,864 KB
testcase_20 AC 498 ms
148,736 KB
testcase_21 AC 501 ms
148,480 KB
testcase_22 AC 497 ms
148,864 KB
testcase_23 AC 500 ms
148,736 KB
testcase_24 AC 495 ms
148,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
	p = 10**9+7
	Comb = [[0]*76 for i in xrange(76)]
	Comb[0][0] = 1
	Gx,Gy,K = map(int,raw_input().split())
	assert -10**5 <= Gx <= 10**5
	assert -10**5 <= Gy <= 10**5
	assert 1 <= K <= 5
	G = (Gx,Gy)
	for i in xrange(K*15):
		for j in xrange(i+2):
			Comb[i+1][j] = (Comb[i][j] + (Comb[i][j-1] if j > 0 else 0)) % p
	dp = [None]*(1<<(4*K))
	dp[0] = (0,0)
	ans = 0
	check_set = set()
	for i in xrange(K):
		x,y,N = map(int,raw_input().split())
		assert -10**4 <= x <= 10**4
		assert -10**4 <= y <= 10**4
		assert 1 <= N <= 15
		assert (x,y) not in check_set
		check_set.add((x,y))
		shift = 4*i
		for j in xrange(1,N+1):
			mx = j*x; my = j*y
			bit = j<<shift
			for k in xrange(1<<shift):
				if dp[k] is None:
					continue
				dp[k+bit] = (dp[k][0]+mx,dp[k][1]+my)
	for k in xrange(1<<(4*K)):
		if dp[k] != G:
			continue
		total = sum((k>>(i*4))%16 for i in xrange(K))
		tmp = 1
		for i in xrange(K):
			dup_n = (k>>(i*4))%16
			tmp = tmp * Comb[total][dup_n] % p
			total -= dup_n
		ans = (ans + tmp) % p
	print ans
solve()
0