結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー バカらっく
提出日時 2019-09-30 01:28:22
言語 Kotlin
(2.1.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 12,366 ms
コンパイル使用メモリ 444,464 KB
実行使用メモリ 88,600 KB
最終ジャッジ日時 2024-10-03 04:47:17
合計ジャッジ時間 32,943 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
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