結果

問題 No.1111 コード進行
ユーザー rlangevinrlangevin
提出日時 2023-02-10 12:41:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 785 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 259,852 KB
最終ジャッジ日時 2023-09-21 15:03:02
合計ジャッジ時間 11,559 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
79,160 KB
testcase_01 AC 81 ms
78,388 KB
testcase_02 AC 76 ms
72,916 KB
testcase_03 AC 76 ms
72,928 KB
testcase_04 AC 74 ms
72,700 KB
testcase_05 AC 98 ms
78,800 KB
testcase_06 AC 121 ms
83,296 KB
testcase_07 AC 121 ms
86,684 KB
testcase_08 AC 114 ms
85,848 KB
testcase_09 AC 113 ms
80,360 KB
testcase_10 AC 121 ms
90,580 KB
testcase_11 AC 112 ms
84,592 KB
testcase_12 AC 121 ms
83,420 KB
testcase_13 AC 123 ms
82,776 KB
testcase_14 AC 144 ms
84,472 KB
testcase_15 AC 116 ms
89,044 KB
testcase_16 AC 130 ms
83,992 KB
testcase_17 AC 120 ms
90,368 KB
testcase_18 AC 102 ms
85,312 KB
testcase_19 AC 87 ms
78,208 KB
testcase_20 AC 112 ms
80,608 KB
testcase_21 AC 95 ms
86,796 KB
testcase_22 AC 128 ms
89,720 KB
testcase_23 AC 116 ms
85,328 KB
testcase_24 AC 114 ms
83,748 KB
testcase_25 AC 139 ms
90,740 KB
testcase_26 AC 122 ms
88,068 KB
testcase_27 AC 109 ms
79,624 KB
testcase_28 AC 247 ms
206,324 KB
testcase_29 AC 219 ms
201,764 KB
testcase_30 AC 222 ms
162,340 KB
testcase_31 AC 127 ms
94,924 KB
testcase_32 AC 295 ms
240,964 KB
testcase_33 AC 249 ms
94,956 KB
testcase_34 AC 210 ms
149,068 KB
testcase_35 AC 281 ms
241,552 KB
testcase_36 AC 429 ms
106,248 KB
testcase_37 AC 247 ms
118,192 KB
testcase_38 AC 223 ms
135,352 KB
testcase_39 AC 287 ms
133,824 KB
testcase_40 AC 354 ms
120,016 KB
testcase_41 AC 300 ms
197,164 KB
testcase_42 AC 297 ms
124,616 KB
testcase_43 AC 271 ms
100,520 KB
testcase_44 AC 194 ms
151,944 KB
testcase_45 AC 285 ms
149,084 KB
testcase_46 AC 252 ms
192,852 KB
testcase_47 AC 785 ms
127,032 KB
testcase_48 AC 248 ms
259,852 KB
testcase_49 AC 251 ms
259,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(p, c):
    return p * (K + 2) + c

N, M, K = map(int, input().split())
mod = 10 ** 9 + 7
G = [[] for i in range(305)]
for i in range(M):
    P, Q, C = map(int, input().split())
    P, Q = P - 1, Q - 1
    G[P].append((Q, C))

pre = [0] * (305 * 305)
for i in range(301):
    pre[f(i, 0)] = 1

for i in range(N - 1):
    dp = [0] * (305 * 305)
    for j in range(301):
        for c in range(K + 2):
            for u, C in G[j]:
                dp[f(u, min(K + 1, c + C))] += pre[f(j, c)]
                dp[f(u, min(K + 1, c + C))] %= mod
    dp, pre = pre, dp

ans = 0
for i in range(301):
    ans += pre[f(i, K)]
    ans %= mod
print(ans)
0