結果

問題 No.632 穴埋め門松列
ユーザー ichibanshiboriichibanshibori
提出日時 2018-05-02 23:37:41
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 304 ms / 1,000 ms
コード長 574 bytes
コンパイル時間 12,848 ms
コンパイル使用メモリ 424,232 KB
実行使用メモリ 57,316 KB
最終ジャッジ日時 2023-08-12 23:31:11
合計ジャッジ時間 15,268 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
57,276 KB
testcase_01 AC 298 ms
56,892 KB
testcase_02 AC 298 ms
57,020 KB
testcase_03 AC 303 ms
57,092 KB
testcase_04 AC 304 ms
57,316 KB
testcase_05 AC 300 ms
57,012 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args : Array<String>) {
         ^

ソースコード

diff #

fun main(args : Array<String>) {
	val aLst = (readLine() ?: "").split(" ").map{ if (it == "?") null else it.toInt() }

	listOf(1, 4)
		.map { Pair(it, replaceNull(aLst, it)) }
		.filter { isKadomatsu(it.second) }
		.map { it.first }
		.joinToString("")
		.let { println(it) }
}

fun replaceNull(aLst : List<Int?>, num : Int) : List<Int> {
	return aLst.map { it ?: num }
}

fun isKadomatsu(nLst : List<Int>) : Boolean {
	return (nLst[0] != nLst[1] && nLst[1] != nLst[2] && nLst[0] != nLst[2])
	    && (nLst[1] < minOf(nLst[0], nLst[2]) || nLst[1] > maxOf(nLst[0], nLst[2]))
}
0