結果
問題 | No.1111 コード進行 |
ユーザー | 箱星 |
提出日時 | 2020-07-10 21:49:49 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 1,723 ms / 2,000 ms |
コード長 | 3,584 bytes |
コンパイル時間 | 16,569 ms |
コンパイル使用メモリ | 455,364 KB |
実行使用メモリ | 117,620 KB |
最終ジャッジ日時 | 2024-10-11 08:53:05 |
合計ジャッジ時間 | 42,032 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 291 ms
49,956 KB |
testcase_01 | AC | 289 ms
49,992 KB |
testcase_02 | AC | 285 ms
50,040 KB |
testcase_03 | AC | 283 ms
49,864 KB |
testcase_04 | AC | 288 ms
49,880 KB |
testcase_05 | AC | 363 ms
62,744 KB |
testcase_06 | AC | 390 ms
85,740 KB |
testcase_07 | AC | 360 ms
66,156 KB |
testcase_08 | AC | 343 ms
59,360 KB |
testcase_09 | AC | 370 ms
67,244 KB |
testcase_10 | AC | 356 ms
83,004 KB |
testcase_11 | AC | 337 ms
60,188 KB |
testcase_12 | AC | 384 ms
84,552 KB |
testcase_13 | AC | 370 ms
71,872 KB |
testcase_14 | AC | 395 ms
85,592 KB |
testcase_15 | AC | 357 ms
55,568 KB |
testcase_16 | AC | 397 ms
84,080 KB |
testcase_17 | AC | 354 ms
83,604 KB |
testcase_18 | AC | 354 ms
56,932 KB |
testcase_19 | AC | 344 ms
54,612 KB |
testcase_20 | AC | 376 ms
64,492 KB |
testcase_21 | AC | 291 ms
50,644 KB |
testcase_22 | AC | 392 ms
85,436 KB |
testcase_23 | AC | 365 ms
70,964 KB |
testcase_24 | AC | 371 ms
76,984 KB |
testcase_25 | AC | 429 ms
89,036 KB |
testcase_26 | AC | 405 ms
83,872 KB |
testcase_27 | AC | 342 ms
57,144 KB |
testcase_28 | AC | 704 ms
90,504 KB |
testcase_29 | AC | 486 ms
85,488 KB |
testcase_30 | AC | 657 ms
90,712 KB |
testcase_31 | AC | 400 ms
89,008 KB |
testcase_32 | AC | 575 ms
86,324 KB |
testcase_33 | AC | 628 ms
90,300 KB |
testcase_34 | AC | 608 ms
89,128 KB |
testcase_35 | AC | 646 ms
87,068 KB |
testcase_36 | AC | 935 ms
90,660 KB |
testcase_37 | AC | 483 ms
84,712 KB |
testcase_38 | AC | 479 ms
84,812 KB |
testcase_39 | AC | 802 ms
90,776 KB |
testcase_40 | AC | 845 ms
89,980 KB |
testcase_41 | AC | 760 ms
90,068 KB |
testcase_42 | AC | 540 ms
86,024 KB |
testcase_43 | AC | 550 ms
87,672 KB |
testcase_44 | AC | 434 ms
85,872 KB |
testcase_45 | AC | 621 ms
87,644 KB |
testcase_46 | AC | 346 ms
58,268 KB |
testcase_47 | AC | 1,723 ms
117,620 KB |
testcase_48 | AC | 358 ms
59,812 KB |
testcase_49 | AC | 348 ms
57,916 KB |
ソースコード
import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.io.PrintWriter import java.util.* // ModInt // region class ModInt(x: Long) { companion object { const val MOD = 1000000007L //const val MOD = 998244353L } val x = (x % MOD + MOD) % MOD operator fun plus(other: ModInt): ModInt { return ModInt(x + other.x) } operator fun minus(other: ModInt): ModInt { return ModInt(x - other.x) } operator fun times(other: ModInt): ModInt { return ModInt(x * other.x) } operator fun div(other: ModInt): ModInt { return this * other.inv() } fun pow(exp: Long): ModInt { if (exp == 0L) return ModInt(1L) var a = pow(exp shr 1) a *= a if (exp and 1L == 0L) return a return this * a } fun inv(): ModInt { return this.pow(MOD - 2) } override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as ModInt if (x != other.x) return false return true } override fun hashCode(): Int { return x.hashCode() } override fun toString(): String { return "$x" } } val fac = mutableListOf<ModInt>() val invfac = mutableListOf<ModInt>() fun fact(n: Long, b: Boolean): ModInt { if (fac.count() == 0) { fac.add(ModInt(1)) invfac.add(ModInt(1)) } while (fac.count() <= n) { fac.add(fac.last() * ModInt(fac.count().toLong())) invfac.add(fac.last().inv()) } return if (b) { fac[n.toInt()] } else { invfac[n.toInt()] } } fun comb(n: Long, k: Long): ModInt { return fact(n, true) * fact(k, false) * fact(n - k, false) } fun comb2(n: Long, k: Long): ModInt { var ans = ModInt(1) for (i in 0 until k) { ans = ans * ModInt(n - i) / ModInt(k - i) } return ans } // endregion fun PrintWriter.solve(sc: FastScanner) { val n = sc.nextInt() val m = sc.nextInt() val k = sc.nextInt() val code = mutableListOf<Triple<Int, Int, Int>>() val next = Array(300) { mutableListOf<Pair<Int, Int>>() } for (i in 0 until m) { val p = sc.nextInt() - 1 val q = sc.nextInt() - 1 val c = sc.nextInt() code.add(Triple(p, q, c)) next[p].add(q to c) } var dp = Array(300) { Array(k + 1) { ModInt(0) } } for (i in 0 until 300) { dp[i][0] = ModInt(1) } for (i in 1 until n) { val newdp = Array(300) { Array(k + 1) { ModInt(0) } } for (j in 0 until 300) { for (s in 0..k) { for ((x, c) in next[j]) { if (s + c > k) continue newdp[x][s + c] += dp[j][s] } } } dp = newdp } var sum = ModInt(0) for (i in 0 until 300) { sum += dp[i][k] } println(sum) } fun main() { val writer = PrintWriter(System.out, false) writer.solve(FastScanner(System.`in`)) writer.flush() } class FastScanner(s: InputStream) { private var st = StringTokenizer("") private val br = BufferedReader(InputStreamReader(s)) fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() fun ready() = br.ready() }