結果
問題 | No.1111 コード進行 |
ユーザー | 👑 箱 |
提出日時 | 2020-07-10 21:49:49 |
言語 | Kotlin (1.9.10) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,584 bytes |
コンパイル時間 | 18,415 ms |
コンパイル使用メモリ | 428,652 KB |
実行使用メモリ | 78,872 KB |
最終ジャッジ日時 | 2023-08-01 17:35:29 |
合計ジャッジ時間 | 48,381 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 266 ms
52,356 KB |
testcase_01 | AC | 265 ms
52,568 KB |
testcase_02 | AC | 264 ms
50,112 KB |
testcase_03 | AC | 262 ms
50,224 KB |
testcase_04 | AC | 267 ms
50,216 KB |
testcase_05 | AC | 352 ms
62,132 KB |
testcase_06 | AC | 361 ms
66,232 KB |
testcase_07 | AC | 344 ms
55,952 KB |
testcase_08 | AC | 321 ms
55,920 KB |
testcase_09 | AC | 346 ms
60,308 KB |
testcase_10 | AC | 337 ms
59,920 KB |
testcase_11 | AC | 313 ms
55,708 KB |
testcase_12 | AC | 372 ms
66,260 KB |
testcase_13 | AC | 356 ms
59,928 KB |
testcase_14 | AC | 389 ms
68,276 KB |
testcase_15 | AC | 334 ms
56,552 KB |
testcase_16 | AC | 367 ms
66,120 KB |
testcase_17 | AC | 342 ms
61,940 KB |
testcase_18 | AC | 326 ms
56,568 KB |
testcase_19 | AC | 321 ms
57,576 KB |
testcase_20 | AC | 344 ms
59,992 KB |
testcase_21 | AC | 275 ms
52,200 KB |
testcase_22 | AC | 363 ms
70,200 KB |
testcase_23 | AC | 339 ms
59,264 KB |
testcase_24 | AC | 350 ms
59,956 KB |
testcase_25 | AC | 390 ms
68,208 KB |
testcase_26 | AC | 376 ms
60,804 KB |
testcase_27 | AC | 313 ms
57,552 KB |
testcase_28 | AC | 1,112 ms
76,696 KB |
testcase_29 | AC | 447 ms
74,296 KB |
testcase_30 | AC | 881 ms
78,872 KB |
testcase_31 | AC | 382 ms
74,604 KB |
testcase_32 | AC | 540 ms
74,424 KB |
testcase_33 | AC | 736 ms
76,164 KB |
testcase_34 | AC | 795 ms
76,136 KB |
testcase_35 | AC | 754 ms
75,644 KB |
testcase_36 | AC | 1,395 ms
75,652 KB |
testcase_37 | AC | 418 ms
56,336 KB |
testcase_38 | AC | 439 ms
56,400 KB |
testcase_39 | AC | 1,056 ms
76,612 KB |
testcase_40 | AC | 1,188 ms
76,640 KB |
testcase_41 | AC | 1,181 ms
76,944 KB |
testcase_42 | AC | 520 ms
70,360 KB |
testcase_43 | AC | 579 ms
76,160 KB |
testcase_44 | AC | 408 ms
61,972 KB |
testcase_45 | AC | 743 ms
75,704 KB |
testcase_46 | AC | 323 ms
55,756 KB |
testcase_47 | TLE | - |
testcase_48 | AC | 333 ms
56,264 KB |
testcase_49 | AC | 327 ms
56,032 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() }