結果

問題 No.455 冬の大三角
ユーザー qszhuqszhu
提出日時 2022-10-08 19:57:51
言語 Kotlin
(1.9.23)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,326 bytes
コンパイル時間 14,995 ms
コンパイル使用メモリ 424,100 KB
実行使用メモリ 59,632 KB
最終ジャッジ日時 2023-09-05 01:31:11
合計ジャッジ時間 38,761 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 319 ms
57,320 KB
testcase_01 AC 330 ms
57,356 KB
testcase_02 AC 322 ms
57,512 KB
testcase_03 AC 318 ms
57,172 KB
testcase_04 AC 318 ms
57,768 KB
testcase_05 AC 320 ms
59,312 KB
testcase_06 AC 320 ms
57,444 KB
testcase_07 AC 313 ms
57,160 KB
testcase_08 AC 338 ms
57,504 KB
testcase_09 AC 322 ms
59,300 KB
testcase_10 AC 336 ms
57,780 KB
testcase_11 AC 322 ms
59,232 KB
testcase_12 AC 326 ms
57,188 KB
testcase_13 AC 317 ms
59,552 KB
testcase_14 AC 314 ms
57,452 KB
testcase_15 AC 320 ms
59,312 KB
testcase_16 AC 319 ms
57,496 KB
testcase_17 AC 321 ms
59,112 KB
testcase_18 AC 315 ms
59,384 KB
testcase_19 AC 313 ms
57,284 KB
testcase_20 AC 318 ms
57,420 KB
testcase_21 AC 328 ms
59,236 KB
testcase_22 AC 322 ms
59,304 KB
testcase_23 AC 318 ms
57,740 KB
testcase_24 AC 325 ms
57,328 KB
testcase_25 AC 315 ms
59,248 KB
testcase_26 AC 320 ms
57,568 KB
testcase_27 AC 317 ms
59,316 KB
testcase_28 AC 318 ms
59,232 KB
testcase_29 AC 341 ms
57,340 KB
testcase_30 AC 325 ms
59,164 KB
testcase_31 AC 325 ms
59,276 KB
testcase_32 AC 327 ms
59,408 KB
testcase_33 AC 346 ms
59,292 KB
testcase_34 AC 321 ms
57,308 KB
testcase_35 AC 343 ms
59,144 KB
testcase_36 AC 328 ms
59,224 KB
testcase_37 AC 323 ms
59,348 KB
testcase_38 AC 321 ms
57,564 KB
testcase_39 AC 341 ms
59,472 KB
testcase_40 AC 332 ms
59,212 KB
testcase_41 AC 335 ms
59,336 KB
testcase_42 AC 322 ms
59,280 KB
testcase_43 AC 324 ms
59,632 KB
testcase_44 AC 325 ms
57,428 KB
testcase_45 AC 346 ms
59,244 KB
testcase_46 AC 328 ms
57,868 KB
testcase_47 AC 331 ms
57,264 KB
testcase_48 AC 322 ms
59,188 KB
testcase_49 WA -
testcase_50 AC 317 ms
57,540 KB
testcase_51 AC 315 ms
59,232 KB
testcase_52 AC 318 ms
59,288 KB
testcase_53 AC 326 ms
59,456 KB
testcase_54 AC 320 ms
57,200 KB
testcase_55 AC 325 ms
59,272 KB
testcase_56 AC 322 ms
59,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import kotlin.random.Random
import kotlin.system.exitProcess

val br = System.`in`.bufferedReader()

fun readLine(): String? = br.readLine()
fun readString() = readLine()!!
fun readStrings() = readLine()?.split(" ")?.filter { it.isNotEmpty() } ?: listOf()
fun readInts() = readStrings().map { it.toInt() }.toIntArray()

const val MAX_STACK_SIZE: Long = 128 * 1024 * 1024

fun main() {
    val thread = Thread(null, ::run, "solve", MAX_STACK_SIZE)
    thread.setUncaughtExceptionHandler { _, e -> e.printStackTrace(); exitProcess(1) }
    thread.start()
}

fun run() {
    val (H, W) = readInts()
    val S = Array(H) { readString().toCharArray() }
    output(solve(H, W, S))
}

fun solve(H: Int, W: Int, S: Array<CharArray>): Array<CharArray> {
    while (true) {
        val r = Random.nextInt(H)
        val c = Random.nextInt(W)
        if (S[r][c] == '*') continue

        var sameCol = 0
        for (r0 in 0 until H) {
            if (S[r0][c] == '*') sameCol++
        }
        if (sameCol > 1) continue

        var sameRow = 0
        for (c0 in 0 until W) {
            if (S[r][c0] == '*') sameRow++
        }
        if (sameRow > 1) continue

        S[r][c] = '*'
        return S
    }
}

fun output(res: Array<CharArray>) =
    res.joinToString("\n") { it.joinToString("") }
        .apply { println(this) }
0