結果

問題 No.1111 コード進行
ユーザー DriceDrice
提出日時 2020-07-10 23:01:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 33,920 KB
実行使用メモリ 218,112 KB
最終ジャッジ日時 2024-04-19 22:22:34
合計ジャッジ時間 2,729 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 6 ms
6,656 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 5 ms
6,784 KB
testcase_29 AC 15 ms
16,768 KB
testcase_30 AC 13 ms
12,544 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 24 ms
18,048 KB
testcase_33 AC 20 ms
11,904 KB
testcase_34 AC 5 ms
6,272 KB
testcase_35 AC 8 ms
9,216 KB
testcase_36 AC 136 ms
106,240 KB
testcase_37 AC 91 ms
88,320 KB
testcase_38 AC 47 ms
44,544 KB
testcase_39 AC 41 ms
26,112 KB
testcase_40 AC 102 ms
84,864 KB
testcase_41 AC 25 ms
25,728 KB
testcase_42 AC 103 ms
94,464 KB
testcase_43 AC 62 ms
53,504 KB
testcase_44 AC 29 ms
30,848 KB
testcase_45 AC 51 ms
48,896 KB
testcase_46 AC 15 ms
18,304 KB
testcase_47 AC 73 ms
19,328 KB
testcase_48 AC 205 ms
218,112 KB
testcase_49 AC 151 ms
162,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
struct Element{
    int a,b;
    int c;
};
long long f[305][305][305];
Element e[305];
const long long mod = 1e9+7;

int main(){
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i = 1; i <= m; i++){
        int p,q,c;
        scanf("%d%d%d",&p,&q,&c);
        e[i].a = p, e[i].b = q, e[i].c = c;
        f[2][q][c] = (f[2][q][c]+1)%mod;
    }
    for(int i = 2; i <= n-1; i++){
        for(int j = 0; j <= k; j++){
            for(int t = 1; t <= m; t++){
                int nextK = j+e[t].c;
                if(nextK<=k){ 
                    //printf("from %d %d %d to %d %d %d\n",i,e[t].a,j,i+1,e[t].b,nextK);
                    f[i+1][e[t].b][nextK] += f[i][e[t].a][j];
                    if(f[i+1][e[t].b][nextK]>=mod) f[i+1][e[t].b][nextK] -= mod;
                }
            }
        }
    }
    long long ans = 0;
    for(int i = 1; i <= 300; i++) ans = (ans+f[n][i][k])%mod;
    printf("%lld\n",ans);
    return 0;
}
0