結果

問題 No.92 逃走経路
ユーザー バカらっくバカらっく
提出日時 2019-09-28 06:49:53
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,609 bytes
コンパイル時間 16,748 ms
コンパイル使用メモリ 457,800 KB
実行使用メモリ 64,820 KB
最終ジャッジ日時 2024-04-08 13:57:44
合計ジャッジ時間 31,107 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 321 ms
54,608 KB
testcase_02 AC 321 ms
54,608 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 414 ms
57,976 KB
testcase_06 AC 432 ms
58,128 KB
testcase_07 AC 429 ms
58,128 KB
testcase_08 AC 365 ms
57,020 KB
testcase_09 AC 937 ms
64,276 KB
testcase_10 WA -
testcase_11 AC 829 ms
64,440 KB
testcase_12 AC 890 ms
64,752 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:4:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
         ^
Main.kt:5:9: warning: variable 'cityCount' is never used
    val(cityCount, roadCount, logCount) = readLine()!!.split(" ").map { it.toInt() }
        ^
Main.kt:5:31: warning: variable 'logCount' is never used
    val(cityCount, roadCount, logCount) = readLine()!!.split(" ").map { it.toInt() }
                              ^

ソースコード

diff #

import kotlin.math.PI


fun main(arr:Array<String>) {
    val(cityCount, roadCount, logCount) = readLine()!!.split(" ").map { it.toInt() }
    val roads = mutableMapOf<Int,MutableMap<Int, MutableMap<Long, Boolean>>>()
    (0 until roadCount).forEach {
        val(city1, city2, cost) = readLine()!!.split(" ").map { it.toInt() }
        if(!roads.containsKey(city1)) {
            roads[city1] = mutableMapOf()
        }
        if(!roads.containsKey(city2)) {
            roads[city2] = mutableMapOf()
        }
        if(!roads[city1]!!.containsKey(city2)) {
            roads[city1]!![city2] = mutableMapOf()
        }
        if(!roads[city2]!!.containsKey(city1)) {
            roads[city2]!![city1] = mutableMapOf()
        }

        roads[city1]!![city2]!![cost.toLong()] = true
        roads[city2]!![city1]!![cost.toLong()] = true
    }

    val log = readLine()!!.split(" ").map { it.toLong() }
    val ans = Proc(roads, log).getAns()
    println(ans.size)
    println(ans.joinToString(" "))
}

class Proc(val roads:Map<Int, Map<Int,Map<Long, Boolean>>>, val log:List<Long>) {
    public fun getAns():List<Int> {


        var currentList = roads.map { a->a.value.filter { b-> log[0] in b.value.keys }.map { it.key }.toMutableList() }.reduce { acc, list -> acc.union(list).toMutableList() }.toList()
        for(i in log.drop(1)) {
            currentList = currentList.map { a->roads[a]?.let { b-> b.filter { i in it.value.keys }.keys.toMutableList() }?: mutableListOf() }.reduce { acc, mutableList -> acc.union(mutableList).toMutableList() }.toList()
        }
        return currentList
    }
}
0