結果

問題 No.1111 コード進行
ユーザー nephrologistnephrologist
提出日時 2020-07-10 22:04:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,697 ms / 2,000 ms
コード長 951 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 296,444 KB
最終ジャッジ日時 2024-04-19 17:13:19
合計ジャッジ時間 12,961 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
60,160 KB
testcase_01 AC 51 ms
60,160 KB
testcase_02 AC 42 ms
52,608 KB
testcase_03 AC 43 ms
52,736 KB
testcase_04 AC 41 ms
52,608 KB
testcase_05 AC 74 ms
78,400 KB
testcase_06 AC 96 ms
80,896 KB
testcase_07 AC 93 ms
80,312 KB
testcase_08 AC 75 ms
74,880 KB
testcase_09 AC 87 ms
78,976 KB
testcase_10 AC 95 ms
83,096 KB
testcase_11 AC 71 ms
73,728 KB
testcase_12 AC 97 ms
80,768 KB
testcase_13 AC 92 ms
79,744 KB
testcase_14 AC 127 ms
83,420 KB
testcase_15 AC 72 ms
72,832 KB
testcase_16 AC 99 ms
81,584 KB
testcase_17 AC 90 ms
83,072 KB
testcase_18 AC 63 ms
70,016 KB
testcase_19 AC 57 ms
64,768 KB
testcase_20 AC 72 ms
73,728 KB
testcase_21 AC 55 ms
63,488 KB
testcase_22 AC 108 ms
85,668 KB
testcase_23 AC 89 ms
79,360 KB
testcase_24 AC 85 ms
80,128 KB
testcase_25 AC 112 ms
84,608 KB
testcase_26 AC 96 ms
80,768 KB
testcase_27 AC 84 ms
77,228 KB
testcase_28 AC 343 ms
186,352 KB
testcase_29 AC 221 ms
124,084 KB
testcase_30 AC 308 ms
148,824 KB
testcase_31 AC 110 ms
88,704 KB
testcase_32 AC 359 ms
143,872 KB
testcase_33 AC 405 ms
118,656 KB
testcase_34 AC 273 ms
155,904 KB
testcase_35 AC 332 ms
180,560 KB
testcase_36 AC 710 ms
185,344 KB
testcase_37 AC 303 ms
105,928 KB
testcase_38 AC 248 ms
97,872 KB
testcase_39 AC 451 ms
148,096 KB
testcase_40 AC 589 ms
176,896 KB
testcase_41 AC 404 ms
199,256 KB
testcase_42 AC 375 ms
127,836 KB
testcase_43 AC 410 ms
120,536 KB
testcase_44 AC 179 ms
101,132 KB
testcase_45 AC 340 ms
151,552 KB
testcase_46 AC 86 ms
83,580 KB
testcase_47 AC 1,697 ms
296,444 KB
testcase_48 AC 64 ms
74,240 KB
testcase_49 AC 66 ms
74,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

mod = 10 ** 9 + 7
n, m, k = map(int, readline().split())
mm = map(int, read().split())
PQC = zip(mm, mm, mm)

jisho = [{} for _ in range(300)]

for p, q, c in PQC:
    p -= 1
    q -= 1
    jisho[p][q] = c

# dp[i][j][k]: i番目まで前がjで、合計kとなる組み合わせ
dp = [[[0] * (k + 1) for _ in range(300)] for _ in range(n)]

for j in range(300):
    dp[0][j][0] = 1
for i in range(n - 1):
    for j in range(300):
        for a in range(k + 1):
            ni = i + 1
            dic = jisho[j]
            for idx, val in dic.items():
                if val + a > k:
                    continue
                nj = idx
                na = val + a
                dp[ni][nj][na] += dp[i][j][a]
                dp[ni][nj][na] %= mod
ans = 0
for j in range(300):
    ans += dp[-1][j][k]
    ans%=mod
print(ans%mod)
0