結果
問題 | No.1111 コード進行 |
ユーザー | yakamoto |
提出日時 | 2020-07-10 22:06:07 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 627 ms / 2,000 ms |
コード長 | 3,304 bytes |
コンパイル時間 | 17,104 ms |
コンパイル使用メモリ | 453,808 KB |
実行使用メモリ | 60,708 KB |
最終ジャッジ日時 | 2024-10-11 09:20:30 |
合計ジャッジ時間 | 38,739 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 316 ms
57,760 KB |
testcase_01 | AC | 320 ms
59,924 KB |
testcase_02 | AC | 313 ms
57,576 KB |
testcase_03 | AC | 312 ms
57,920 KB |
testcase_04 | AC | 314 ms
57,748 KB |
testcase_05 | AC | 355 ms
60,212 KB |
testcase_06 | AC | 374 ms
60,188 KB |
testcase_07 | AC | 384 ms
60,540 KB |
testcase_08 | AC | 382 ms
60,396 KB |
testcase_09 | AC | 401 ms
60,364 KB |
testcase_10 | AC | 373 ms
60,276 KB |
testcase_11 | AC | 385 ms
60,552 KB |
testcase_12 | AC | 380 ms
60,540 KB |
testcase_13 | AC | 376 ms
60,536 KB |
testcase_14 | AC | 411 ms
60,708 KB |
testcase_15 | AC | 358 ms
58,616 KB |
testcase_16 | AC | 395 ms
60,444 KB |
testcase_17 | AC | 352 ms
60,172 KB |
testcase_18 | AC | 352 ms
60,100 KB |
testcase_19 | AC | 324 ms
59,528 KB |
testcase_20 | AC | 372 ms
60,452 KB |
testcase_21 | AC | 322 ms
59,944 KB |
testcase_22 | AC | 381 ms
60,644 KB |
testcase_23 | AC | 365 ms
60,504 KB |
testcase_24 | AC | 381 ms
60,432 KB |
testcase_25 | AC | 407 ms
60,688 KB |
testcase_26 | AC | 400 ms
60,556 KB |
testcase_27 | AC | 380 ms
60,360 KB |
testcase_28 | AC | 385 ms
60,520 KB |
testcase_29 | AC | 370 ms
60,528 KB |
testcase_30 | AC | 402 ms
60,448 KB |
testcase_31 | AC | 350 ms
60,396 KB |
testcase_32 | AC | 456 ms
60,460 KB |
testcase_33 | AC | 449 ms
60,456 KB |
testcase_34 | AC | 371 ms
60,432 KB |
testcase_35 | AC | 389 ms
60,360 KB |
testcase_36 | AC | 521 ms
60,604 KB |
testcase_37 | AC | 406 ms
58,400 KB |
testcase_38 | AC | 404 ms
58,584 KB |
testcase_39 | AC | 457 ms
60,400 KB |
testcase_40 | AC | 478 ms
60,500 KB |
testcase_41 | AC | 403 ms
60,448 KB |
testcase_42 | AC | 442 ms
60,704 KB |
testcase_43 | AC | 434 ms
60,360 KB |
testcase_44 | AC | 400 ms
58,700 KB |
testcase_45 | AC | 397 ms
60,040 KB |
testcase_46 | AC | 383 ms
60,648 KB |
testcase_47 | AC | 627 ms
60,404 KB |
testcase_48 | AC | 383 ms
60,416 KB |
testcase_49 | AC | 379 ms
60,404 KB |
ソースコード
import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.util.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min val MOD = 1_000_000_007L data class Trans(val p: Int, val q: Int, val c: Int) class Solver(stream: InputStream, private val out: java.io.PrintWriter) { fun solve() { val N = ni() val M = ni() val K = ni() val T = Array(M){Trans(ni() - 1, ni() - 1, ni())} val map = Array(300){mutableListOf<Trans>()} for (t in T) { map[t.p].add(t) } var best = Array(K + 1){LongArray(300)} var next = Array(K + 1){LongArray(300)} for (i in 0 until 300) { best[0][i] = 1 } for (times in 0 until N - 1) { for (k in 0 .. K) { Arrays.fill(next[k], 0) } for (k in 0 .. K) { for (p in 0 until 300) { for (i in 0 until map[p].size) { val t = map[p][i] if (k + t.c <= K) { next[k + t.c][t.q] += best[k][p] next[k + t.c][t.q] %= MOD } } } } debug{"$times"} debugDim(next) val tmp = best best = next next = tmp } out.println(best[K].sum() % MOD) } private val isDebug = try { // なんか本番でエラーでる System.getenv("MY_DEBUG") != null } catch (t: Throwable) { false } private var tokenizer: StringTokenizer? = null private val reader = BufferedReader(InputStreamReader(stream), 32768) private fun next(): String { while (tokenizer == null || !tokenizer!!.hasMoreTokens()) { tokenizer = StringTokenizer(reader.readLine()) } return tokenizer!!.nextToken() } private fun ni() = next().toInt() private fun nl() = next().toLong() private fun ns() = next() private fun na(n: Int, offset: Int = 0): IntArray { return map(n) { ni() + offset } } private fun nal(n: Int, offset: Int = 0): LongArray { val res = LongArray(n) for (i in 0 until n) { res[i] = nl() + offset } return res } private fun na2(n: Int, offset: Int = 0): Array<IntArray> { val a = Array(2){IntArray(n)} for (i in 0 until n) { for (e in a) { e[i] = ni() + offset } } return a } private inline fun map(n: Int, f: (Int) -> Int): IntArray { val res = IntArray(n) for (i in 0 until n) { res[i] = f(i) } return res } private inline fun debug(msg: () -> String) { if (isDebug) System.err.println(msg()) } private fun debug(a: LongArray) { debug { a.joinToString(" ") } } private fun debug(a: IntArray) { debug { a.joinToString(" ") } } private fun debug(a: BooleanArray) { debug { a.map { if (it) 1 else 0 }.joinToString("") } } private fun debugDim(A: Array<LongArray>) { if (isDebug) { for (a in A) { debug(a) } } } private fun debugDim(A: Array<IntArray>) { if (isDebug) { for (a in A) { debug(a) } } } /** * 勝手にimport消されるのを防ぎたい */ private fun hoge() { min(1, 2) max(1, 2) abs(-10) } } fun main() { val out = java.io.PrintWriter(System.out) Solver(System.`in`, out).solve() out.flush() }