結果
問題 | No.1111 コード進行 |
ユーザー | 箱星 |
提出日時 | 2020-07-10 21:46:09 |
言語 | Kotlin (1.9.23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,518 bytes |
コンパイル時間 | 20,529 ms |
コンパイル使用メモリ | 463,336 KB |
実行使用メモリ | 108,384 KB |
最終ジャッジ日時 | 2024-10-11 13:09:43 |
合計ジャッジ時間 | 36,922 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 302 ms
53,164 KB |
testcase_01 | AC | 311 ms
85,432 KB |
testcase_02 | AC | 314 ms
49,916 KB |
testcase_03 | AC | 316 ms
49,920 KB |
testcase_04 | AC | 303 ms
49,624 KB |
testcase_05 | AC | 384 ms
63,852 KB |
testcase_06 | AC | 406 ms
70,500 KB |
testcase_07 | AC | 432 ms
67,456 KB |
testcase_08 | AC | 406 ms
56,520 KB |
testcase_09 | AC | 394 ms
64,420 KB |
testcase_10 | AC | 424 ms
76,180 KB |
testcase_11 | AC | 390 ms
56,568 KB |
testcase_12 | AC | 410 ms
71,328 KB |
testcase_13 | AC | 423 ms
65,360 KB |
testcase_14 | AC | 472 ms
105,380 KB |
testcase_15 | AC | 380 ms
55,524 KB |
testcase_16 | AC | 429 ms
74,204 KB |
testcase_17 | AC | 396 ms
77,224 KB |
testcase_18 | AC | 360 ms
56,896 KB |
testcase_19 | AC | 345 ms
55,576 KB |
testcase_20 | AC | 399 ms
62,444 KB |
testcase_21 | AC | 312 ms
50,792 KB |
testcase_22 | AC | 465 ms
108,084 KB |
testcase_23 | AC | 369 ms
62,456 KB |
testcase_24 | AC | 393 ms
67,452 KB |
testcase_25 | AC | 511 ms
108,384 KB |
testcase_26 | AC | 414 ms
74,356 KB |
testcase_27 | AC | 371 ms
57,136 KB |
testcase_28 | TLE | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
ソースコード
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) } val dp = Array(n+1) { Array(300) { Array(k + 1) { ModInt(0) } } } for (i in 0 until 300) { dp[1][i][0] = ModInt(1) } for (i in 1 until n) { for (j in 0 until 300) { for (s in 0..k) { for ((x, c) in next[j]) { if (s + c > k) continue dp[i+1][x][s+c] += dp[i][j][s] } } } } var sum = ModInt(0) for (i in 0 until 300) { sum += dp[n][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() }