結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー roarisroaris
提出日時 2019-12-16 16:31:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 754 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 8,712 KB
最終ジャッジ日時 2023-09-15 17:55:37
合計ジャッジ時間 4,040 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,544 KB
testcase_01 AC 20 ms
8,712 KB
testcase_02 AC 20 ms
8,704 KB
testcase_03 AC 20 ms
8,572 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def inv(x):
    return pow(x, MOD-2, MOD)
    
def dfs(d, q):
    if d==K:
        x, y = 0, 0
        res = fact[sum(q)]
        
        for (xi, yi, _), qi in zip(xyN, q):
            x += xi*qi
            y += yi*qi
            res *= inv(fact[qi])
            
        if x==Gx and y==Gy:
            return res
        else:
            return 0
            
    res = 0
    
    for i in range(xyN[d][2]+1):
        q.append(i)
        res += dfs(d+1, q)
        res %= MOD
        q.pop()
    
    return res

Gx, Gy, K = map(int, input().split())
xyN = [tuple(map(int, input().split())) for _ in range(K)]
MOD = 10**9+7
fact = [1]

for i in range(1, 100):
    fact.append(fact[-1]*i%MOD)

print(dfs(0, deque([])))
0