結果

問題 No.179 塗り分け
ユーザー komkomhkomkomh
提出日時 2019-05-16 08:32:40
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,162 ms / 3,000 ms
コード長 1,319 bytes
コンパイル時間 19,706 ms
コンパイル使用メモリ 424,072 KB
実行使用メモリ 60,356 KB
最終ジャッジ日時 2023-09-30 21:13:22
合計ジャッジ時間 36,623 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 296 ms
53,196 KB
testcase_01 AC 288 ms
53,024 KB
testcase_02 AC 295 ms
53,164 KB
testcase_03 AC 295 ms
53,260 KB
testcase_04 AC 300 ms
53,296 KB
testcase_05 AC 295 ms
53,144 KB
testcase_06 AC 350 ms
56,028 KB
testcase_07 AC 306 ms
53,144 KB
testcase_08 AC 364 ms
55,888 KB
testcase_09 AC 363 ms
55,844 KB
testcase_10 AC 715 ms
56,156 KB
testcase_11 AC 669 ms
56,288 KB
testcase_12 AC 1,162 ms
60,356 KB
testcase_13 AC 306 ms
53,020 KB
testcase_14 AC 302 ms
53,072 KB
testcase_15 AC 292 ms
53,068 KB
testcase_16 AC 292 ms
53,228 KB
testcase_17 AC 298 ms
54,896 KB
testcase_18 AC 560 ms
56,096 KB
testcase_19 AC 529 ms
56,172 KB
testcase_20 AC 303 ms
53,264 KB
testcase_21 AC 300 ms
53,100 KB
testcase_22 AC 458 ms
56,224 KB
testcase_23 AC 470 ms
55,988 KB
testcase_24 AC 437 ms
55,948 KB
testcase_25 AC 395 ms
55,948 KB
testcase_26 AC 458 ms
55,972 KB
testcase_27 AC 593 ms
56,252 KB
testcase_28 AC 546 ms
56,092 KB
testcase_29 AC 753 ms
56,148 KB
testcase_30 AC 658 ms
56,356 KB
testcase_31 AC 834 ms
56,380 KB
testcase_32 AC 652 ms
56,288 KB
testcase_33 AC 838 ms
56,072 KB
testcase_34 AC 691 ms
56,108 KB
testcase_35 AC 930 ms
56,116 KB
testcase_36 AC 297 ms
53,004 KB
testcase_37 AC 296 ms
53,168 KB
testcase_38 AC 297 ms
53,116 KB
testcase_39 AC 297 ms
53,028 KB
testcase_40 AC 301 ms
53,096 KB
testcase_41 AC 295 ms
53,084 KB
testcase_42 AC 299 ms
53,024 KB
testcase_43 AC 348 ms
55,768 KB
testcase_44 AC 400 ms
55,836 KB
testcase_45 AC 330 ms
56,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder


fun main() {
    val (h, w) = readLine()!!.split(" ").map(String::toInt)
    val blacks = (0 until h).flatMap { h2 ->
        readLine()!!
            .mapIndexed { index, c -> Pair(index, c) }
            .filter { it.second != '.' }
            .map { Pair(h2, it.first) }
    }

    if (blacks.isEmpty() || blacks.size % 2 != 0) {
        println("NO")
        return
    }

    fun canCopy(): Boolean {
        for (moveH in -h until h) {
            for (moveW in -w until w) {
                if (moveH == 0 && moveW == 0) {
                    continue
                }

                var tmpBlacks = blacks.toMutableSet()
                for (red in blacks) {
                    if (!tmpBlacks.contains(red)) {
                        continue
                    }
                    val blue = Pair(red.first + moveH, red.second + moveW)
                    if (!tmpBlacks.contains(blue)) {
                        break
                    }
                    tmpBlacks.remove(red)
                    tmpBlacks.remove(blue)
                }
                if (tmpBlacks.isEmpty()) {
                    return true
                }
            }
        }
        return false
    }

    when (canCopy()) {
        true -> println("YES")
        false -> println("NO")
    }
}
0