結果

問題 No.1111 コード進行
ユーザー ks2mks2m
提出日時 2020-07-10 22:02:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 681 ms / 2,000 ms
コード長 1,679 bytes
コンパイル時間 2,081 ms
コンパイル使用メモリ 79,112 KB
実行使用メモリ 256,204 KB
最終ジャッジ日時 2024-04-19 17:09:39
合計ジャッジ時間 9,634 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
37,028 KB
testcase_01 AC 47 ms
36,864 KB
testcase_02 AC 50 ms
36,332 KB
testcase_03 AC 48 ms
36,848 KB
testcase_04 AC 48 ms
36,468 KB
testcase_05 AC 50 ms
38,968 KB
testcase_06 AC 75 ms
45,428 KB
testcase_07 AC 80 ms
45,568 KB
testcase_08 AC 60 ms
38,668 KB
testcase_09 AC 71 ms
39,692 KB
testcase_10 AC 58 ms
44,480 KB
testcase_11 AC 54 ms
38,320 KB
testcase_12 AC 87 ms
45,988 KB
testcase_13 AC 56 ms
39,760 KB
testcase_14 AC 100 ms
46,116 KB
testcase_15 AC 50 ms
37,500 KB
testcase_16 AC 87 ms
45,472 KB
testcase_17 AC 53 ms
44,276 KB
testcase_18 AC 49 ms
37,696 KB
testcase_19 AC 46 ms
37,364 KB
testcase_20 AC 50 ms
38,812 KB
testcase_21 AC 49 ms
37,296 KB
testcase_22 AC 56 ms
48,596 KB
testcase_23 AC 54 ms
39,768 KB
testcase_24 AC 53 ms
43,888 KB
testcase_25 AC 105 ms
50,920 KB
testcase_26 AC 86 ms
45,500 KB
testcase_27 AC 51 ms
37,804 KB
testcase_28 AC 181 ms
180,932 KB
testcase_29 AC 135 ms
102,768 KB
testcase_30 AC 176 ms
122,536 KB
testcase_31 AC 63 ms
52,532 KB
testcase_32 AC 214 ms
122,812 KB
testcase_33 AC 185 ms
81,104 KB
testcase_34 AC 156 ms
122,168 KB
testcase_35 AC 161 ms
138,432 KB
testcase_36 AC 333 ms
177,532 KB
testcase_37 AC 157 ms
66,976 KB
testcase_38 AC 153 ms
66,552 KB
testcase_39 AC 261 ms
122,504 KB
testcase_40 AC 261 ms
137,460 KB
testcase_41 AC 199 ms
180,944 KB
testcase_42 AC 202 ms
102,388 KB
testcase_43 AC 222 ms
82,316 KB
testcase_44 AC 137 ms
67,592 KB
testcase_45 AC 191 ms
122,956 KB
testcase_46 AC 87 ms
41,980 KB
testcase_47 AC 681 ms
256,204 KB
testcase_48 AC 110 ms
45,232 KB
testcase_49 AC 114 ms
45,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		int max = 301;
		List<List<Obj>> list = new ArrayList<>(max);
		for (int i = 0; i < max; i++) {
			list.add(new ArrayList<>());
		}
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int p = Integer.parseInt(sa[0]);
			Obj o = new Obj();
			o.q = Integer.parseInt(sa[1]);
			o.c = Integer.parseInt(sa[2]);
			list.get(p).add(o);
			set.add(p);
		}
		br.close();

		int mod = 1000000007;
		// x個、最後がy、複雑度z
		long[][][] dp = new long[n][max][k + 1];
		for (int y : set) {
			dp[0][y][0] = 1;
		}
		for (int x = 0; x < n - 1; x++) {
			for (int y : set) {
				for (Obj next : list.get(y)) {
					for (int z = 0; z <= k; z++) {
						if (z + next.c <= k) {
							dp[x + 1][next.q][z + next.c] += dp[x][y][z];
							dp[x + 1][next.q][z + next.c] %= mod;
						}
					}
				}
			}
//			for (int y = 0; y < 5; y++) {
//				for (int z = 0; z <= k; z++) {
//					System.out.print(dp[x + 1][y][z] + "\t");
//				}
//				System.out.println();
//			}
//			System.out.println();
		}

		long ans = 0;
		for (int y = 0; y < max; y++) {
			ans += dp[n - 1][y][k];
		}
		ans %= mod;
		System.out.println(ans);
	}

	static class Obj {
		int q, c;
	}
}
0