結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー roarisroaris
提出日時 2019-12-16 16:31:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 754 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 83,820 KB
最終ジャッジ日時 2023-09-15 17:50:20
合計ジャッジ時間 4,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
76,308 KB
testcase_01 AC 92 ms
71,288 KB
testcase_02 AC 92 ms
71,604 KB
testcase_03 AC 93 ms
71,564 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