結果

問題 No.179 塗り分け
ユーザー rutilicus
提出日時 2020-09-02 21:50:27
言語 Kotlin
(2.1.0)
結果
WA  
実行時間 -
コード長 1,149 bytes
コンパイル時間 15,090 ms
コンパイル使用メモリ 442,176 KB
実行使用メモリ 71,268 KB
最終ジャッジ日時 2024-11-21 22:00:14
合計ジャッジ時間 32,859 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 33 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:43: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 #

import kotlin.math.max

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

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

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

    print(builder.toString())
}

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