結果
問題 |
No.1111 コード進行
|
ユーザー |
![]() |
提出日時 | 2020-10-11 11:31:27 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 736 ms / 2,000 ms |
コード長 | 1,357 bytes |
コンパイル時間 | 15,352 ms |
コンパイル使用メモリ | 448,620 KB |
実行使用メモリ | 263,584 KB |
最終ジャッジ日時 | 2024-07-20 17:12:36 |
合計ジャッジ時間 | 36,230 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 48 |
コンパイルメッセージ
Main.kt:50:13: warning: 'appendln(Long): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator. builder.appendln(ans) ^
ソースコード
fun main() { val builder = StringBuilder() val allCodeNum = 300 val mod = 1000000007L val (n, m, k) = readInputLine().split(" ").map { it.toInt() } val codes = Array(allCodeNum) { mutableListOf<Pair<Int, Int>>() } repeat(m) { val (p, q, c) = readInputLine().split(" ").map { it.toInt() } codes[p - 1].add(Pair(q - 1, c)) } // dp[step][complex][last code] val dp = Array(n - 1) { Array(k + 1) { LongArray(allCodeNum) } } for (i in 0 until allCodeNum) { for (c in codes[i]) { if (c.second <= k) { dp[0][c.second][c.first] += 1L } } } for (i in 0 until n - 2) { for (j in 0..k) { for (l in 0 until allCodeNum) { if (dp[i][j][l] != 0L) { for (c in codes[l]) { if (j + c.second <= k) { dp[i + 1][j + c.second][c.first] += dp[i][j][l] dp[i + 1][j + c.second][c.first] %= mod } } } } } } var ans = 0L for (i in 0 until allCodeNum) { ans += dp[n - 2][k][i] ans %= mod } builder.appendln(ans) print(builder.toString()) } fun readInputLine(): String { return readLine()!! }