結果

問題 No.1638 Robot Maze
ユーザー face4face4
提出日時 2021-08-06 22:34:59
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,266 bytes
コンパイル時間 17,316 ms
コンパイル使用メモリ 446,956 KB
実行使用メモリ 58,840 KB
最終ジャッジ日時 2023-10-17 04:03:09
合計ジャッジ時間 35,099 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 330 ms
58,636 KB
testcase_01 WA -
testcase_02 AC 327 ms
58,624 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 330 ms
58,632 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 360 ms
58,840 KB
testcase_17 WA -
testcase_18 AC 366 ms
58,824 KB
testcase_19 AC 371 ms
58,824 KB
testcase_20 AC 371 ms
58,812 KB
testcase_21 AC 365 ms
58,820 KB
testcase_22 AC 363 ms
58,824 KB
testcase_23 WA -
testcase_24 AC 363 ms
58,816 KB
testcase_25 AC 364 ms
58,840 KB
testcase_26 WA -
testcase_27 AC 364 ms
58,824 KB
testcase_28 AC 363 ms
58,812 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 363 ms
58,812 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 367 ms
58,828 KB
testcase_43 AC 363 ms
58,828 KB
testcase_44 AC 366 ms
58,828 KB
testcase_45 AC 367 ms
58,828 KB
testcase_46 AC 366 ms
58,812 KB
testcase_47 AC 368 ms
58,824 KB
testcase_48 AC 365 ms
58,824 KB
testcase_49 AC 362 ms
58,828 KB
testcase_50 AC 359 ms
58,824 KB
testcase_51 AC 365 ms
58,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*

data class Data(val dist: Long, val pos: Int) : Comparable<Data> {
    override fun compareTo(other: Data): Int {
        return if (dist - other.dist > 0) 1 else -1
    }
}

fun main() {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val line = readLine()!!.split(" ").map { it.toLong() }
    val (si, sj, ti, tj) = readLine()!!.split(" ").map { it.toInt() - 1 }
    val di = listOf(-1, 1, 0, 0)
    val dj = listOf(0, 0, 1, -1)
    val mat = (0 until h).map { readLine()!! }

    val d = List(h) { MutableList(w) { 1L shl 60 } }
    d[si][sj] = 0
    val pq = PriorityQueue<Data>()
    pq.add(Data(d[si][sj], si * w + sj))
    while (pq.isNotEmpty()) {
        val (dist, pos) = pq.poll()
        val i = pos / w
        val j = pos % w
        if (d[i][j] != dist) continue
        for (k in 0 until 4) {
            val ni = i + di[k]
            val nj = j + dj[k]
            if (ni !in 0 until h || nj !in 0 until w || mat[ni][nj] == '#') continue
            val ndist = dist + (if (mat[ni][nj] == '@') line[5] else 0) + line[k]
            if (d[ni][nj] >= ndist) continue
            d[ni][nj] = ndist
            pq.add(Data(ndist, ni * w + nj))
        }
    }
    println(if (d[ti][tj] <= line[4]) "Yes" else "No")
}
0