結果

問題 No.1111 コード進行
ユーザー ronpooronpoo
提出日時 2023-09-07 14:59:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 410 ms / 2,000 ms
コード長 795 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 297,852 KB
最終ジャッジ日時 2023-09-07 14:59:20
合計ジャッジ時間 9,752 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,660 KB
testcase_01 AC 74 ms
75,468 KB
testcase_02 AC 73 ms
71,340 KB
testcase_03 AC 78 ms
71,340 KB
testcase_04 AC 77 ms
71,464 KB
testcase_05 AC 80 ms
76,052 KB
testcase_06 AC 86 ms
76,240 KB
testcase_07 AC 88 ms
76,412 KB
testcase_08 AC 85 ms
76,776 KB
testcase_09 AC 87 ms
76,512 KB
testcase_10 AC 82 ms
76,148 KB
testcase_11 AC 87 ms
76,616 KB
testcase_12 AC 91 ms
76,716 KB
testcase_13 AC 80 ms
76,136 KB
testcase_14 AC 102 ms
84,576 KB
testcase_15 AC 85 ms
76,532 KB
testcase_16 AC 87 ms
76,500 KB
testcase_17 AC 83 ms
76,072 KB
testcase_18 AC 78 ms
76,248 KB
testcase_19 AC 73 ms
71,468 KB
testcase_20 AC 78 ms
76,276 KB
testcase_21 AC 78 ms
76,340 KB
testcase_22 AC 81 ms
76,592 KB
testcase_23 AC 81 ms
76,516 KB
testcase_24 AC 82 ms
76,332 KB
testcase_25 AC 105 ms
86,108 KB
testcase_26 AC 99 ms
76,492 KB
testcase_27 AC 78 ms
76,140 KB
testcase_28 AC 191 ms
181,644 KB
testcase_29 AC 135 ms
112,852 KB
testcase_30 AC 218 ms
150,344 KB
testcase_31 AC 104 ms
89,696 KB
testcase_32 AC 260 ms
145,332 KB
testcase_33 AC 246 ms
112,432 KB
testcase_34 AC 175 ms
157,500 KB
testcase_35 AC 195 ms
181,164 KB
testcase_36 AC 262 ms
180,788 KB
testcase_37 AC 154 ms
106,628 KB
testcase_38 AC 199 ms
98,764 KB
testcase_39 AC 355 ms
149,244 KB
testcase_40 AC 410 ms
178,216 KB
testcase_41 AC 202 ms
181,928 KB
testcase_42 AC 186 ms
129,100 KB
testcase_43 AC 289 ms
121,564 KB
testcase_44 AC 108 ms
90,360 KB
testcase_45 AC 164 ms
135,824 KB
testcase_46 AC 94 ms
76,716 KB
testcase_47 AC 349 ms
297,852 KB
testcase_48 AC 109 ms
84,652 KB
testcase_49 AC 90 ms
76,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
PQC = [list(map(int, input().split())) for _ in range(M)]
MOD = 10**9 + 7

d = dict()
for i in range(M):
    p, q, c = PQC[i]
    p -= 1
    q -= 1
    if p not in d:
        d[p] = []
    d[p].append((q, c))

dp = [[[0]*(K+1) for _ in range(300)] for _ in range(N+1)]
for i in range(300):
    if i in d:
        dp[1][i][0] = 1
for i in range(1, N):
    for j in range(300):
        if j not in d:
            continue
        for k in range(K+1):
            if dp[i][j][k] == 0:
                continue
            for x, y in d[j]:
                if k+y <= K:
                    dp[i+1][x][k+y] += dp[i][j][k]
                    dp[i+1][x][k+y] %= MOD
                    
ans = 0
for i in range(300):
    ans += dp[N][i][K]
    ans %= MOD
print(ans)
0