結果

問題 No.1111 コード進行
ユーザー rutilicusrutilicus
提出日時 2020-10-11 11:31:27
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 648 ms / 2,000 ms
コード長 1,357 bytes
コンパイル時間 14,592 ms
コンパイル使用メモリ 426,324 KB
実行使用メモリ 293,860 KB
最終ジャッジ日時 2023-09-27 22:53:04
合計ジャッジ時間 37,601 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 255 ms
52,952 KB
testcase_01 AC 254 ms
53,164 KB
testcase_02 AC 255 ms
53,052 KB
testcase_03 AC 255 ms
52,988 KB
testcase_04 AC 254 ms
52,876 KB
testcase_05 AC 263 ms
55,116 KB
testcase_06 AC 312 ms
57,528 KB
testcase_07 AC 314 ms
57,484 KB
testcase_08 AC 299 ms
55,588 KB
testcase_09 AC 316 ms
57,412 KB
testcase_10 AC 299 ms
56,256 KB
testcase_11 AC 292 ms
55,248 KB
testcase_12 AC 327 ms
57,504 KB
testcase_13 AC 314 ms
56,416 KB
testcase_14 AC 331 ms
57,656 KB
testcase_15 AC 272 ms
53,368 KB
testcase_16 AC 348 ms
57,592 KB
testcase_17 AC 295 ms
56,428 KB
testcase_18 AC 277 ms
55,316 KB
testcase_19 AC 261 ms
52,972 KB
testcase_20 AC 324 ms
55,556 KB
testcase_21 AC 259 ms
52,944 KB
testcase_22 AC 295 ms
56,568 KB
testcase_23 AC 291 ms
56,500 KB
testcase_24 AC 303 ms
56,320 KB
testcase_25 AC 326 ms
57,576 KB
testcase_26 AC 346 ms
57,736 KB
testcase_27 AC 265 ms
53,168 KB
testcase_28 AC 471 ms
193,572 KB
testcase_29 AC 345 ms
90,152 KB
testcase_30 AC 477 ms
132,276 KB
testcase_31 AC 305 ms
66,496 KB
testcase_32 AC 470 ms
114,360 KB
testcase_33 AC 495 ms
87,216 KB
testcase_34 AC 395 ms
131,084 KB
testcase_35 AC 394 ms
143,680 KB
testcase_36 AC 475 ms
194,932 KB
testcase_37 AC 376 ms
76,524 KB
testcase_38 AC 368 ms
68,024 KB
testcase_39 AC 589 ms
131,660 KB
testcase_40 AC 648 ms
191,412 KB
testcase_41 AC 465 ms
193,912 KB
testcase_42 AC 394 ms
114,760 KB
testcase_43 AC 535 ms
112,244 KB
testcase_44 AC 312 ms
74,876 KB
testcase_45 AC 401 ms
131,092 KB
testcase_46 AC 335 ms
54,992 KB
testcase_47 AC 636 ms
293,860 KB
testcase_48 AC 312 ms
56,296 KB
testcase_49 AC 287 ms
53,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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)
            ^

ソースコード

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