結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー バカらっくバカらっく
提出日時 2019-09-30 01:32:24
言語 Kotlin
(1.9.23)
結果
TLE  
実行時間 -
コード長 876 bytes
コンパイル時間 26,336 ms
コンパイル使用メモリ 441,936 KB
実行使用メモリ 95,520 KB
最終ジャッジ日時 2024-04-14 07:38:44
合計ジャッジ時間 29,515 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 317 ms
60,280 KB
testcase_01 AC 365 ms
95,520 KB
testcase_02 AC 366 ms
64,432 KB
testcase_03 AC 372 ms
59,420 KB
testcase_04 AC 353 ms
57,316 KB
testcase_05 AC 376 ms
57,540 KB
testcase_06 AC 351 ms
57,168 KB
testcase_07 AC 376 ms
57,588 KB
testcase_08 AC 374 ms
57,592 KB
testcase_09 AC 383 ms
57,468 KB
testcase_10 AC 390 ms
57,464 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
         ^

ソースコード

diff #

import kotlin.math.max

fun main(arr:Array<String>) {
    val columnCount = readLine()!!.toInt()
    val barCount = readLine()!!.toInt()
    val barMap = (0 until barCount).map { readLine()!!.split(" ").map { it.toInt() - 1 } }

    val moveTo = (0 until columnCount).map {
        getGoal(it, barMap)
    }

    var numList = (0 until columnCount).map { it }
    for(i in (1..10000000)) {
        var tmp = numList.withIndex().sortedBy { moveTo[it.index] }.map { it.value }
        numList = tmp
        if(numList.withIndex().all { it.index == it.value }) {
            println(i)
            return
        }
    }

}

fun getGoal(column:Int, barMap:List<List<Int>>):Int {
    var current = column
    for((f,t) in barMap) {
        if(f == current) {
            current = t
        } else if(current == t) {
            current = f
        }
    }
    return current
}


0