結果

問題 No.632 穴埋め門松列
ユーザー ichibanshiboriichibanshibori
提出日時 2018-05-02 23:37:41
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 346 ms / 1,000 ms
コード長 574 bytes
コンパイル時間 13,894 ms
コンパイル使用メモリ 444,128 KB
実行使用メモリ 60,380 KB
最終ジャッジ日時 2024-04-30 18:27:01
合計ジャッジ時間 16,079 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 343 ms
60,320 KB
testcase_01 AC 346 ms
60,232 KB
testcase_02 AC 343 ms
60,380 KB
testcase_03 AC 344 ms
60,252 KB
testcase_04 AC 338 ms
60,240 KB
testcase_05 AC 340 ms
60,236 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