結果

問題 No.1111 コード進行
ユーザー 37zigen37zigen
提出日時 2020-07-10 22:39:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,066 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 209,576 KB
最終ジャッジ日時 2023-08-01 18:42:32
合計ジャッジ時間 11,995 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,368 KB
testcase_01 AC 78 ms
71,192 KB
testcase_02 AC 77 ms
71,144 KB
testcase_03 AC 79 ms
71,192 KB
testcase_04 AC 78 ms
71,196 KB
testcase_05 AC 84 ms
75,892 KB
testcase_06 AC 117 ms
79,480 KB
testcase_07 AC 111 ms
78,476 KB
testcase_08 AC 106 ms
76,884 KB
testcase_09 AC 101 ms
75,996 KB
testcase_10 AC 110 ms
78,740 KB
testcase_11 AC 103 ms
76,432 KB
testcase_12 AC 119 ms
79,464 KB
testcase_13 AC 99 ms
76,556 KB
testcase_14 AC 120 ms
79,672 KB
testcase_15 AC 95 ms
76,692 KB
testcase_16 AC 116 ms
79,932 KB
testcase_17 AC 104 ms
78,484 KB
testcase_18 AC 87 ms
76,184 KB
testcase_19 AC 83 ms
75,744 KB
testcase_20 AC 95 ms
75,884 KB
testcase_21 AC 86 ms
76,056 KB
testcase_22 AC 105 ms
79,316 KB
testcase_23 AC 101 ms
76,468 KB
testcase_24 AC 106 ms
78,640 KB
testcase_25 AC 121 ms
79,164 KB
testcase_26 AC 122 ms
79,020 KB
testcase_27 AC 93 ms
76,300 KB
testcase_28 AC 132 ms
87,144 KB
testcase_29 AC 119 ms
78,760 KB
testcase_30 AC 407 ms
105,744 KB
testcase_31 AC 104 ms
79,276 KB
testcase_32 AC 684 ms
117,684 KB
testcase_33 AC 695 ms
134,556 KB
testcase_34 AC 125 ms
83,904 KB
testcase_35 AC 130 ms
83,152 KB
testcase_36 AC 330 ms
87,032 KB
testcase_37 AC 163 ms
78,252 KB
testcase_38 AC 291 ms
83,456 KB
testcase_39 AC 1,066 ms
209,576 KB
testcase_40 AC 632 ms
116,808 KB
testcase_41 AC 154 ms
88,064 KB
testcase_42 AC 206 ms
79,968 KB
testcase_43 AC 467 ms
99,296 KB
testcase_44 AC 124 ms
78,200 KB
testcase_45 AC 168 ms
82,448 KB
testcase_46 AC 108 ms
77,104 KB
testcase_47 AC 674 ms
100,048 KB
testcase_48 AC 101 ms
77,272 KB
testcase_49 AC 101 ms
77,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD=10**9+7

n=300

N,M,K=map(int,input().split())
P=[0]*M
Q=[0]*M
C=[0]*M

for i in range(M):
    P[i],Q[i],C[i]=map(int,input().split())
    P[i]-=1
    Q[i]-=1

dp0=[[0]*(K+1) for i in range(n)]
dp1=[[0]*(K+1) for i in range(n)]

for i in range(n):
    dp0[i][0]=1

for t in range(N-1):
    for i in range(M):
        for num in range(K+1):
            nnum=num+C[i]
            if nnum>K:
                continue
            if t%2==0:
                dp1[Q[i]][nnum]+=dp0[P[i]][num]
                if dp1[Q[i]][num]>=MOD:
                    dp1[Q[i]][nnum]-=MOD
            else:
                dp0[Q[i]][nnum]+=dp1[P[i]][num]
                if dp0[Q[i]][nnum]>=MOD:
                    dp0[Q[i]][nnum]-=MOD

    if t%2==0:
        dp0=[[0]*(K+1) for i in range(n)]
    else:
        dp1=[[0]*(K+1) for i in range(n)]

ans=0
for i in range(n):
    ans=(ans+dp0[i][K]+dp1[i][K])%MOD
print(ans)
0