結果

問題 No.179 塗り分け
ユーザー rutilicusrutilicus
提出日時 2020-09-02 21:56:04
言語 Kotlin
(1.9.10)
結果
AC  
実行時間 443 ms / 3,000 ms
コード長 1,220 bytes
コンパイル時間 15,086 ms
コンパイル使用メモリ 424,812 KB
実行使用メモリ 58,496 KB
最終ジャッジ日時 2023-09-30 21:32:56
合計ジャッジ時間 34,705 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 316 ms
56,824 KB
testcase_01 AC 315 ms
56,908 KB
testcase_02 AC 316 ms
56,852 KB
testcase_03 AC 319 ms
56,932 KB
testcase_04 AC 320 ms
56,916 KB
testcase_05 AC 346 ms
56,980 KB
testcase_06 AC 328 ms
56,804 KB
testcase_07 AC 327 ms
56,996 KB
testcase_08 AC 397 ms
57,184 KB
testcase_09 AC 412 ms
57,316 KB
testcase_10 AC 369 ms
56,924 KB
testcase_11 AC 369 ms
56,880 KB
testcase_12 AC 400 ms
57,380 KB
testcase_13 AC 323 ms
56,928 KB
testcase_14 AC 326 ms
56,880 KB
testcase_15 AC 319 ms
56,820 KB
testcase_16 AC 324 ms
56,784 KB
testcase_17 AC 321 ms
56,844 KB
testcase_18 AC 364 ms
56,984 KB
testcase_19 AC 362 ms
56,924 KB
testcase_20 AC 382 ms
57,528 KB
testcase_21 AC 443 ms
57,304 KB
testcase_22 AC 397 ms
56,984 KB
testcase_23 AC 367 ms
57,464 KB
testcase_24 AC 408 ms
57,420 KB
testcase_25 AC 366 ms
57,236 KB
testcase_26 AC 395 ms
57,248 KB
testcase_27 AC 417 ms
57,736 KB
testcase_28 AC 386 ms
57,236 KB
testcase_29 AC 413 ms
57,384 KB
testcase_30 AC 390 ms
57,448 KB
testcase_31 AC 419 ms
57,360 KB
testcase_32 AC 392 ms
57,508 KB
testcase_33 AC 415 ms
57,480 KB
testcase_34 AC 386 ms
57,512 KB
testcase_35 AC 411 ms
57,380 KB
testcase_36 AC 329 ms
56,964 KB
testcase_37 AC 332 ms
56,924 KB
testcase_38 AC 327 ms
56,744 KB
testcase_39 AC 324 ms
56,920 KB
testcase_40 AC 326 ms
56,832 KB
testcase_41 AC 327 ms
56,856 KB
testcase_42 AC 324 ms
56,816 KB
testcase_43 AC 336 ms
56,876 KB
testcase_44 AC 342 ms
58,496 KB
testcase_45 AC 331 ms
56,928 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:45:13: warning: 'appendln(String?): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
    builder.appendln(if (ok) "YES" else "NO")
            ^

ソースコード

diff #

fun main() {
    val builder = StringBuilder()

    val (h, w) = readInputLine().split(" ").map { it.toInt() }

    val map = Array(h) { readInputLine().toCharArray() }

    var ok = false

    for (i in -h until h) {
        if (ok) {
            break
        }
        for (j in -w until w) {
            val tmp = Array(h) { map[it].copyOf() }
            var ng = false

            for (k in 0 until h) {
                if (ng) {
                    break
                }
                for (l in 0 until w) {
                    if (tmp[k][l] == '#') {
                        tmp[k][l] = 'r'
                        if (k + i < 0 || k + i >= h || l + j < 0 || l + j >= w || tmp[k + i][l + j] != '#') {
                            ng = true
                            break
                        }
                        tmp[k + i][l + j] = 'b'
                    }
                }
            }

            if (!ng) {
                ok = true
                break
            }
        }
    }

    if (!map.any { it.contains('#') }) {
        ok = false
    }

    builder.appendln(if (ok) "YES" else "NO")

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0