結果

問題 No.1111 コード進行
コンテスト
ユーザー rutilicus
提出日時 2020-10-11 11:31:27
言語 Kotlin
(2.1.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,357 bytes
コンパイル時間 9,662 ms
コンパイル使用メモリ 426,488 KB
最終ジャッジ日時 2025-11-14 07:25:07
合計ジャッジ時間 10,233 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Main.kt:50:13: error: 'fun StringBuilder.appendln(value: Long): 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)
            ^^^^^^^^

ソースコード

diff #

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()!!
}
0