結果

問題 No.1111 コード進行
ユーザー tcltktcltk
提出日時 2021-01-17 15:21:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 956 ms / 2,000 ms
コード長 1,231 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 81,868 KB
実行使用メモリ 308,444 KB
最終ジャッジ日時 2024-05-07 04:34:57
合計ジャッジ時間 17,951 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
89,344 KB
testcase_01 AC 147 ms
89,088 KB
testcase_02 AC 143 ms
89,208 KB
testcase_03 AC 144 ms
88,884 KB
testcase_04 AC 150 ms
88,932 KB
testcase_05 AC 148 ms
89,460 KB
testcase_06 AC 161 ms
89,508 KB
testcase_07 AC 171 ms
89,776 KB
testcase_08 AC 179 ms
89,728 KB
testcase_09 AC 153 ms
89,856 KB
testcase_10 AC 162 ms
89,600 KB
testcase_11 AC 162 ms
89,848 KB
testcase_12 AC 162 ms
89,600 KB
testcase_13 AC 153 ms
89,628 KB
testcase_14 AC 179 ms
89,856 KB
testcase_15 AC 166 ms
89,472 KB
testcase_16 AC 163 ms
89,704 KB
testcase_17 AC 159 ms
89,476 KB
testcase_18 AC 154 ms
89,600 KB
testcase_19 AC 144 ms
89,348 KB
testcase_20 AC 151 ms
89,600 KB
testcase_21 AC 159 ms
89,472 KB
testcase_22 AC 170 ms
89,472 KB
testcase_23 AC 161 ms
89,728 KB
testcase_24 AC 155 ms
89,728 KB
testcase_25 AC 196 ms
102,272 KB
testcase_26 AC 167 ms
89,472 KB
testcase_27 AC 151 ms
89,900 KB
testcase_28 AC 342 ms
216,848 KB
testcase_29 AC 334 ms
198,392 KB
testcase_30 AC 293 ms
160,848 KB
testcase_31 AC 174 ms
104,960 KB
testcase_32 AC 549 ms
253,620 KB
testcase_33 AC 330 ms
142,076 KB
testcase_34 AC 308 ms
198,272 KB
testcase_35 AC 424 ms
282,228 KB
testcase_36 AC 542 ms
216,448 KB
testcase_37 AC 529 ms
197,888 KB
testcase_38 AC 445 ms
175,872 KB
testcase_39 AC 394 ms
160,844 KB
testcase_40 AC 517 ms
216,700 KB
testcase_41 AC 392 ms
235,136 KB
testcase_42 AC 539 ms
216,576 KB
testcase_43 AC 421 ms
160,524 KB
testcase_44 AC 304 ms
160,896 KB
testcase_45 AC 395 ms
217,036 KB
testcase_46 AC 911 ms
308,444 KB
testcase_47 AC 910 ms
308,424 KB
testcase_48 AC 937 ms
308,420 KB
testcase_49 AC 956 ms
308,428 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 _ in range(N)]
    for j in range(300):
        dp[0][j][0] = 1

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

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

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