結果

問題 No.179 塗り分け
ユーザー yudedakoyudedako
提出日時 2020-08-27 11:14:54
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,146 bytes
コンパイル時間 14,661 ms
コンパイル使用メモリ 444,536 KB
実行使用メモリ 57,244 KB
最終ジャッジ日時 2024-04-25 05:32:01
合計ジャッジ時間 27,767 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 282 ms
52,276 KB
testcase_01 AC 283 ms
52,036 KB
testcase_02 AC 284 ms
52,040 KB
testcase_03 AC 289 ms
52,096 KB
testcase_04 AC 279 ms
52,336 KB
testcase_05 AC 295 ms
52,572 KB
testcase_06 AC 297 ms
52,648 KB
testcase_07 WA -
testcase_08 AC 292 ms
52,648 KB
testcase_09 AC 304 ms
52,420 KB
testcase_10 AC 306 ms
52,448 KB
testcase_11 AC 298 ms
52,744 KB
testcase_12 AC 329 ms
52,968 KB
testcase_13 AC 292 ms
52,412 KB
testcase_14 AC 281 ms
52,280 KB
testcase_15 WA -
testcase_16 AC 291 ms
52,128 KB
testcase_17 WA -
testcase_18 AC 299 ms
52,368 KB
testcase_19 AC 309 ms
52,468 KB
testcase_20 AC 299 ms
52,580 KB
testcase_21 AC 309 ms
52,440 KB
testcase_22 AC 312 ms
52,648 KB
testcase_23 AC 293 ms
52,540 KB
testcase_24 AC 308 ms
52,792 KB
testcase_25 AC 299 ms
52,560 KB
testcase_26 AC 298 ms
52,684 KB
testcase_27 AC 298 ms
52,628 KB
testcase_28 AC 301 ms
52,500 KB
testcase_29 AC 301 ms
52,652 KB
testcase_30 AC 295 ms
52,440 KB
testcase_31 AC 312 ms
52,580 KB
testcase_32 AC 305 ms
52,376 KB
testcase_33 AC 304 ms
52,776 KB
testcase_34 AC 308 ms
52,504 KB
testcase_35 AC 306 ms
52,680 KB
testcase_36 AC 281 ms
52,208 KB
testcase_37 AC 292 ms
52,384 KB
testcase_38 AC 291 ms
52,184 KB
testcase_39 AC 283 ms
52,460 KB
testcase_40 AC 281 ms
52,160 KB
testcase_41 AC 294 ms
52,252 KB
testcase_42 AC 288 ms
52,296 KB
testcase_43 AC 284 ms
52,272 KB
testcase_44 AC 292 ms
52,192 KB
testcase_45 AC 289 ms
52,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


fun main() {
    val (height, width) = readLine()!!.trim().split(' ').map(String::toInt)
    val square = Array(height){readLine()!!.trim()}
    val type = Array(height){IntArray(width){-1} }
    val blackCell = (0 until height).flatMap{h -> (0 until width).filter{w -> square[h][w] == '#'}.map{w -> h to w}}
    var hasPair = true
    outer@for (dh in 0 until height) {
        for (dw in -width + 1 until width) {
            if (dh == 0 && dw == 0) continue
            val count = (dh * width * 2) + dw + width
            hasPair = true
            for ((h, w) in blackCell) {
                if (type[h][w] >= count) continue
                type[h][w] = count
                if (h + dh !in 0 until height || w + dw !in 0 until width) {
                    hasPair = false
                    break
                }
                if (square[h + dh][w + dw] != '#') {
                    hasPair = false
                    break
                }
                type[h + dh][w + dw] = count
            }
            if (hasPair) {
                break@outer
            }
        }
    }
    println(if (hasPair) "YES" else "NO")
}
0