結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー バカらっくバカらっく
提出日時 2019-09-30 01:28:22
言語 Kotlin
(1.9.10)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 16,532 ms
コンパイル使用メモリ 419,648 KB
実行使用メモリ 60,092 KB
最終ジャッジ日時 2023-07-26 18:07:27
合計ジャッジ時間 41,096 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 297 ms
52,948 KB
testcase_01 AC 336 ms
53,380 KB
testcase_02 AC 336 ms
53,380 KB
testcase_03 AC 335 ms
53,344 KB
testcase_04 AC 320 ms
53,096 KB
testcase_05 AC 341 ms
53,424 KB
testcase_06 AC 315 ms
53,160 KB
testcase_07 AC 346 ms
53,392 KB
testcase_08 AC 344 ms
53,452 KB
testcase_09 AC 348 ms
53,420 KB
testcase_10 AC 350 ms
53,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 623 ms
58,004 KB
testcase_21 AC 604 ms
58,096 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 303 ms
53,020 KB
testcase_35 AC 301 ms
53,088 KB
testcase_36 AC 302 ms
53,196 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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..10000)) {
        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