結果

問題 No.1340 おーじ君をさがせ
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-01-15 22:53:40
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,274 ms / 2,000 ms
コード長 1,786 bytes
コンパイル時間 12,681 ms
コンパイル使用メモリ 447,664 KB
実行使用メモリ 81,840 KB
最終ジャッジ日時 2024-05-05 21:57:28
合計ジャッジ時間 54,153 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 306 ms
51,264 KB
testcase_01 AC 311 ms
51,424 KB
testcase_02 AC 312 ms
51,360 KB
testcase_03 AC 317 ms
51,420 KB
testcase_04 AC 315 ms
51,316 KB
testcase_05 AC 305 ms
51,580 KB
testcase_06 AC 316 ms
51,580 KB
testcase_07 AC 316 ms
51,264 KB
testcase_08 AC 309 ms
51,308 KB
testcase_09 AC 313 ms
51,596 KB
testcase_10 AC 343 ms
51,692 KB
testcase_11 AC 491 ms
52,780 KB
testcase_12 AC 389 ms
52,372 KB
testcase_13 AC 482 ms
52,712 KB
testcase_14 AC 710 ms
52,952 KB
testcase_15 AC 638 ms
52,612 KB
testcase_16 AC 385 ms
52,148 KB
testcase_17 AC 466 ms
52,632 KB
testcase_18 AC 536 ms
52,680 KB
testcase_19 AC 359 ms
52,084 KB
testcase_20 AC 385 ms
51,928 KB
testcase_21 AC 689 ms
67,116 KB
testcase_22 AC 871 ms
62,416 KB
testcase_23 AC 731 ms
69,316 KB
testcase_24 AC 1,125 ms
56,664 KB
testcase_25 AC 592 ms
67,644 KB
testcase_26 AC 554 ms
61,976 KB
testcase_27 AC 516 ms
59,216 KB
testcase_28 AC 589 ms
66,928 KB
testcase_29 AC 474 ms
60,972 KB
testcase_30 AC 682 ms
67,632 KB
testcase_31 AC 1,197 ms
69,020 KB
testcase_32 AC 1,012 ms
68,992 KB
testcase_33 AC 974 ms
69,056 KB
testcase_34 AC 997 ms
68,980 KB
testcase_35 AC 992 ms
69,020 KB
testcase_36 AC 311 ms
51,120 KB
testcase_37 AC 483 ms
68,244 KB
testcase_38 AC 1,082 ms
69,368 KB
testcase_39 AC 1,274 ms
81,840 KB
testcase_40 AC 1,187 ms
68,868 KB
testcase_41 AC 1,088 ms
69,344 KB
testcase_42 AC 317 ms
51,320 KB
testcase_43 AC 312 ms
51,636 KB
testcase_44 AC 315 ms
51,384 KB
testcase_45 AC 314 ms
51,444 KB
testcase_46 AC 966 ms
57,088 KB
testcase_47 AC 1,048 ms
57,004 KB
testcase_48 AC 970 ms
57,268 KB
testcase_49 AC 952 ms
53,116 KB
testcase_50 AC 928 ms
53,252 KB
testcase_51 AC 923 ms
53,256 KB
testcase_52 AC 786 ms
53,032 KB
testcase_53 AC 795 ms
53,136 KB
testcase_54 AC 791 ms
52,844 KB
testcase_55 AC 921 ms
55,780 KB
testcase_56 AC 308 ms
51,488 KB
testcase_57 AC 317 ms
51,460 KB
testcase_58 AC 308 ms
51,332 KB
testcase_59 AC 792 ms
52,940 KB
testcase_60 AC 308 ms
51,340 KB
testcase_61 AC 800 ms
52,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder

import kotlin.math.*
import java.util.*

class Main(private val args : Array<String>) : Runnable {
    override fun run() {
        solve(args)
    }
    private fun solve(@Suppress("UNUSED_PARAMETER") args: Array<String>) {
        Scanner(System.`in`).use { sc ->
            val N = sc.nextInt()
            val M = sc.nextInt()
            val T = sc.nextLong()
            val doubling = MutableList(60){MutableList(N){BooleanArray(N)} }
            repeat(M) {
                val a = sc.nextInt()
                val b = sc.nextInt()
                doubling[0][a][b] = true
            }
            for (i in 1 until 60) {
                for (l in 0 until N) {
                    for (r in 0 until N) {
                        for (m in 0 until N) {
                            if (doubling[i - 1][l][m] and doubling[i - 1][m][r]) doubling[i][l][r] = true
                        }
                    }
                }
            }
            var ans = BooleanArray(N)
            ans[0] = true
            for (i in 0 until 60) {
                if ((T shr i and 1) == 0L) continue
                val swap = BooleanArray(N)
                for (l in 0 until N) {
                    for (r in 0 until N) {
                        if (doubling[i][l][r]) swap[r] = swap[r] or ans[l]
                    }
                }
                ans = swap
            }
            println(ans.filter{it}.count())
        }
    }
}

/** 確保するメモリの大きさ(単位: MB)  */
private const val MEMORY: Long = 64

fun main(args: Array<String>) {
    Thread.setDefaultUncaughtExceptionHandler { _: Thread?, e: Throwable ->
        e.printStackTrace()
        System.exit(1)
    }
    Thread(null, Main(args = args), "", MEMORY * 1048576L).start()
}
0