結果
問題 |
No.101 ぐるぐる!あみだくじ!
|
ユーザー |
![]() |
提出日時 | 2019-09-30 01:32:24 |
言語 | Kotlin (2.1.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 876 bytes |
コンパイル時間 | 14,310 ms |
コンパイル使用メモリ | 446,084 KB |
実行使用メモリ | 94,508 KB |
最終ジャッジ日時 | 2024-10-03 04:47:47 |
合計ジャッジ時間 | 25,728 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 11 TLE * 1 -- * 25 |
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'arr' is never used fun main(arr:Array<String>) { ^
ソースコード
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 }