結果
問題 | No.92 逃走経路 |
ユーザー | バカらっく |
提出日時 | 2019-09-28 06:51:12 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 891 ms / 5,000 ms |
コード長 | 1,618 bytes |
コンパイル時間 | 16,669 ms |
コンパイル使用メモリ | 457,140 KB |
実行使用メモリ | 96,264 KB |
最終ジャッジ日時 | 2024-10-01 06:57:25 |
合計ジャッジ時間 | 28,361 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 784 ms
94,232 KB |
testcase_01 | AC | 316 ms
57,052 KB |
testcase_02 | AC | 320 ms
60,296 KB |
testcase_03 | AC | 322 ms
60,536 KB |
testcase_04 | AC | 333 ms
60,400 KB |
testcase_05 | AC | 409 ms
63,080 KB |
testcase_06 | AC | 427 ms
63,176 KB |
testcase_07 | AC | 420 ms
63,248 KB |
testcase_08 | AC | 352 ms
62,804 KB |
testcase_09 | AC | 891 ms
93,212 KB |
testcase_10 | AC | 808 ms
96,264 KB |
testcase_11 | AC | 849 ms
94,224 KB |
testcase_12 | AC | 864 ms
94,512 KB |
testcase_13 | AC | 638 ms
94,136 KB |
testcase_14 | AC | 715 ms
94,360 KB |
testcase_15 | AC | 777 ms
94,404 KB |
testcase_16 | AC | 688 ms
95,300 KB |
testcase_17 | AC | 705 ms
94,368 KB |
testcase_18 | AC | 637 ms
94,292 KB |
testcase_19 | AC | 554 ms
82,700 KB |
コンパイルメッセージ
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() } ^
ソースコード
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.sorted().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 } }