結果

問題 No.3 ビットすごろく
ユーザー バカらっくバカらっく
提出日時 2019-08-29 06:46:40
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,063 ms / 5,000 ms
コード長 876 bytes
コンパイル時間 15,759 ms
コンパイル使用メモリ 420,716 KB
実行使用メモリ 57,756 KB
最終ジャッジ日時 2023-09-14 01:28:25
合計ジャッジ時間 35,983 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 301 ms
55,960 KB
testcase_01 AC 306 ms
56,120 KB
testcase_02 AC 304 ms
56,200 KB
testcase_03 AC 418 ms
57,448 KB
testcase_04 AC 373 ms
57,232 KB
testcase_05 AC 580 ms
57,168 KB
testcase_06 AC 418 ms
57,556 KB
testcase_07 AC 388 ms
57,396 KB
testcase_08 AC 464 ms
57,356 KB
testcase_09 AC 746 ms
57,148 KB
testcase_10 AC 846 ms
57,288 KB
testcase_11 AC 660 ms
57,180 KB
testcase_12 AC 555 ms
57,108 KB
testcase_13 AC 403 ms
57,220 KB
testcase_14 AC 783 ms
57,456 KB
testcase_15 AC 1,008 ms
57,388 KB
testcase_16 AC 942 ms
57,356 KB
testcase_17 AC 1,000 ms
57,364 KB
testcase_18 AC 388 ms
57,476 KB
testcase_19 AC 1,051 ms
57,348 KB
testcase_20 AC 347 ms
56,640 KB
testcase_21 AC 305 ms
56,428 KB
testcase_22 AC 819 ms
57,456 KB
testcase_23 AC 1,035 ms
57,592 KB
testcase_24 AC 1,063 ms
57,756 KB
testcase_25 AC 1,042 ms
57,544 KB
testcase_26 AC 302 ms
55,936 KB
testcase_27 AC 404 ms
57,504 KB
testcase_28 AC 904 ms
57,644 KB
testcase_29 AC 678 ms
57,356 KB
testcase_30 AC 313 ms
56,320 KB
testcase_31 AC 319 ms
56,524 KB
testcase_32 AC 612 ms
57,520 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used
fun main(args: Array<String>){
         ^

ソースコード

diff #

import java.util.*

fun main(args: Array<String>){
    val boxCount = readLine()!!.toInt()
    val box = arrayOfNulls<Int>(boxCount+1)
    val move = box.indices.map { it.toString(2).count { it == '1' }}

    val que = LinkedList<Task>()
    que.push(Task(1, 1))

    while (que.isNotEmpty()) {
        val task = que.pop()
        if(task.pos <= 0) {
            continue
        }
        if(task.pos > boxCount) {
            continue
        }
        if(box[task.pos] == null || box[task.pos]!! > task.step) {
            box[task.pos] = task.step
        } else {
            continue
        }
        que.push(Task(task.pos + move[task.pos], task.step + 1))
        que.push(Task(task.pos - move[task.pos], task.step + 1))
    }
    box[boxCount]?.also {
        println(box[boxCount])
    } ?: run {
        println(-1)
    }
}

class Task(val pos:Int, val step:Int)
0