結果

問題 No.1111 コード進行
ユーザー tcltktcltk
提出日時 2021-01-17 15:21:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 713 ms / 2,000 ms
コード長 1,276 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 86,652 KB
実行使用メモリ 106,392 KB
最終ジャッジ日時 2023-08-19 21:34:35
合計ジャッジ時間 19,165 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 231 ms
83,600 KB
testcase_01 AC 224 ms
83,352 KB
testcase_02 AC 226 ms
83,096 KB
testcase_03 AC 226 ms
83,156 KB
testcase_04 AC 224 ms
83,472 KB
testcase_05 AC 226 ms
83,824 KB
testcase_06 AC 273 ms
87,596 KB
testcase_07 AC 255 ms
87,208 KB
testcase_08 AC 259 ms
87,816 KB
testcase_09 AC 241 ms
87,160 KB
testcase_10 AC 246 ms
86,860 KB
testcase_11 AC 246 ms
87,824 KB
testcase_12 AC 245 ms
87,228 KB
testcase_13 AC 244 ms
87,320 KB
testcase_14 AC 257 ms
88,028 KB
testcase_15 AC 249 ms
87,044 KB
testcase_16 AC 254 ms
87,636 KB
testcase_17 AC 245 ms
87,092 KB
testcase_18 AC 238 ms
86,860 KB
testcase_19 AC 227 ms
83,724 KB
testcase_20 AC 237 ms
86,544 KB
testcase_21 AC 244 ms
86,856 KB
testcase_22 AC 245 ms
86,880 KB
testcase_23 AC 246 ms
87,428 KB
testcase_24 AC 246 ms
87,484 KB
testcase_25 AC 273 ms
87,860 KB
testcase_26 AC 253 ms
87,332 KB
testcase_27 AC 242 ms
87,432 KB
testcase_28 AC 299 ms
97,492 KB
testcase_29 AC 305 ms
96,064 KB
testcase_30 AC 307 ms
93,088 KB
testcase_31 AC 251 ms
87,148 KB
testcase_32 AC 455 ms
101,840 KB
testcase_33 AC 353 ms
90,424 KB
testcase_34 AC 285 ms
94,584 KB
testcase_35 AC 327 ms
103,728 KB
testcase_36 AC 576 ms
97,612 KB
testcase_37 AC 467 ms
95,752 KB
testcase_38 AC 417 ms
92,920 KB
testcase_39 AC 393 ms
93,052 KB
testcase_40 AC 445 ms
97,352 KB
testcase_41 AC 322 ms
99,024 KB
testcase_42 AC 463 ms
97,632 KB
testcase_43 AC 404 ms
93,188 KB
testcase_44 AC 310 ms
92,548 KB
testcase_45 AC 344 ms
95,524 KB
testcase_46 AC 703 ms
106,272 KB
testcase_47 AC 705 ms
106,392 KB
testcase_48 AC 713 ms
105,368 KB
testcase_49 AC 713 ms
106,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """4 6 2
# 1 2 0
# 1 3 0
# 2 1 1
# 3 1 0
# 2 3 0
# 3 2 2
# """
# sys.stdin = io.StringIO(_INPUT)

MOD = 1000000007


def main():
    N, M, K = map(int, input().split())
    P = [None for _ in range(M)]
    Q = [None for _ in range(M)]
    C = [None for _ in range(M)]
    for i in range(M):
        P[i], Q[i], C[i] = map(int, input().split())
        P[i] -= 1
        Q[i] -= 1

    Kmax = 300
    dp = [[0 for _ in range(Kmax+1)] for _ in range(300)]
    for j in range(300):
        dp[j][0] = 1

    for i in range(N-1):
        dp1 = [[0 for _ in range(Kmax+1)] for _ in range(300)]
        for m in range(M):
            for k in range(Kmax+1):
                if k + C[m] <= Kmax:
                    dp1[Q[m]][k+C[m]] = (dp1[Q[m]][k+C[m]] + dp[P[m]][k]) % MOD
        dp = dp1

    n = 0
    for j in range(300):
        n += dp[j][K]
    print(n % MOD)

if __name__ == '__main__':
    main()
0