結果

問題 No.1111 コード進行
ユーザー tentententen
提出日時 2023-11-16 16:29:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 361 ms / 2,000 ms
コード長 2,549 bytes
コンパイル時間 2,662 ms
コンパイル使用メモリ 91,748 KB
実行使用メモリ 197,280 KB
最終ジャッジ日時 2023-11-16 16:29:30
合計ジャッジ時間 11,580 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
53,988 KB
testcase_01 AC 52 ms
53,984 KB
testcase_02 AC 52 ms
53,996 KB
testcase_03 AC 53 ms
53,984 KB
testcase_04 AC 54 ms
53,984 KB
testcase_05 AC 53 ms
53,984 KB
testcase_06 AC 71 ms
56,524 KB
testcase_07 AC 72 ms
56,764 KB
testcase_08 AC 73 ms
54,628 KB
testcase_09 AC 68 ms
54,516 KB
testcase_10 AC 75 ms
56,084 KB
testcase_11 AC 62 ms
54,248 KB
testcase_12 AC 81 ms
57,396 KB
testcase_13 AC 58 ms
53,992 KB
testcase_14 AC 90 ms
60,160 KB
testcase_15 AC 63 ms
54,124 KB
testcase_16 AC 78 ms
57,304 KB
testcase_17 AC 59 ms
56,088 KB
testcase_18 AC 56 ms
54,000 KB
testcase_19 AC 54 ms
53,996 KB
testcase_20 AC 56 ms
53,992 KB
testcase_21 AC 59 ms
53,992 KB
testcase_22 AC 63 ms
58,868 KB
testcase_23 AC 62 ms
54,136 KB
testcase_24 AC 59 ms
56,092 KB
testcase_25 AC 99 ms
60,100 KB
testcase_26 AC 83 ms
57,376 KB
testcase_27 AC 60 ms
54,004 KB
testcase_28 AC 154 ms
116,808 KB
testcase_29 AC 123 ms
80,176 KB
testcase_30 AC 175 ms
92,528 KB
testcase_31 AC 64 ms
58,840 KB
testcase_32 AC 210 ms
91,348 KB
testcase_33 AC 211 ms
82,580 KB
testcase_34 AC 126 ms
95,552 KB
testcase_35 AC 164 ms
116,412 KB
testcase_36 AC 322 ms
121,064 KB
testcase_37 AC 182 ms
70,648 KB
testcase_38 AC 168 ms
68,388 KB
testcase_39 AC 199 ms
92,852 KB
testcase_40 AC 220 ms
119,756 KB
testcase_41 AC 205 ms
133,828 KB
testcase_42 AC 214 ms
83,020 KB
testcase_43 AC 187 ms
81,776 KB
testcase_44 AC 129 ms
68,688 KB
testcase_45 AC 191 ms
94,980 KB
testcase_46 AC 127 ms
61,156 KB
testcase_47 AC 361 ms
197,280 KB
testcase_48 AC 137 ms
60,808 KB
testcase_49 AC 137 ms
61,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        ArrayList<HashMap<Integer, Integer>> graph = new ArrayList<>();
        for (int i = 0; i < 300; i++) {
            graph.add(new HashMap<>());
        }
        for (int i = 0; i < m; i++) {
            graph.get(sc.nextInt() - 1).put(sc.nextInt() - 1, sc.nextInt());
        }
        int[][][] dp = new int[n][300][k + 1];
        for (int i = 0; i < 300; i++) {
            dp[0][i][0] = 1;
        }
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < 300; j++) {
                for (int x : graph.get(j).keySet()) {
                    int y = graph.get(j).get(x);
                    for (int a = 0; a + y <= k; a++) {
                        dp[i][x][a + y] += dp[i - 1][j][a];
                        dp[i][x][a + y] %= MOD;
                    }
                }
                
            }
        }
        int ans = 0;
        for (int i = 0; i < 300; i++) {
            ans += dp[n - 1][i][k];
            ans %= MOD;
        }
        System.out.println(ans);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0