結果

問題 No.179 塗り分け
ユーザー komkomh
提出日時 2019-05-16 08:32:40
言語 Kotlin
(1.3.1)
結果
AC   *
実行時間 1,213 ms
コード長 1,319 Byte
コンパイル時間 8,159 ms
使用メモリ 37,640 KB
最終ジャッジ日時 2019-05-16 08:33:08

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
00_sample1.txt AC 194 ms
27,076 KB
00_sample2.txt AC 190 ms
27,044 KB
00_sample3.txt AC 200 ms
27,180 KB
00_sample4.txt AC 196 ms
27,100 KB
00_sample5.txt AC 221 ms
27,200 KB
00_sample6.txt AC 206 ms
27,476 KB
10_hand01.txt AC 288 ms
35,432 KB
10_hand02.txt AC 227 ms
27,536 KB
10_hand03.txt AC 294 ms
31,660 KB
10_hand04.txt AC 297 ms
31,580 KB
10_hand05.txt AC 753 ms
35,844 KB
10_hand06.txt AC 709 ms
35,936 KB
10_hand07.txt AC 1,213 ms
37,640 KB
10_hand08.txt AC 223 ms
27,288 KB
10_hand09.txt AC 203 ms
27,248 KB
10_hand10.txt AC 187 ms
27,048 KB
10_hand11.txt AC 194 ms
27,040 KB
10_hand12.txt AC 190 ms
27,076 KB
10_hand13.txt AC 560 ms
35,696 KB
10_hand14.txt AC 522 ms
35,848 KB
10_hand15.txt AC 220 ms
27,684 KB
10_hand16.txt AC 217 ms
27,556 KB
10_hand17.txt AC 419 ms
35,628 KB
10_hand18.txt AC 410 ms
35,548 KB
10_hand19.txt AC 365 ms
35,808 KB
10_hand20.txt AC 320 ms
35,472 KB
20_random01.txt AC 427 ms
35,680 KB
20_random02.txt AC 593 ms
35,728 KB
20_random03.txt AC 631 ms
35,692 KB
20_random04.txt AC 793 ms
35,804 KB
20_random05.txt AC 694 ms
35,712 KB
20_random06.txt AC 893 ms
35,800 KB
20_random07.txt AC 691 ms
35,792 KB
20_random08.txt AC 894 ms
35,764 KB
20_random09.txt AC 724 ms
35,800 KB
20_random10.txt AC 1,006 ms
36,032 KB
99_system_test1.txt AC 203 ms
27,080 KB
99_system_test2.txt AC 193 ms
27,016 KB
99_system_test3.txt AC 197 ms
27,108 KB
system_test1.txt AC 200 ms
27,168 KB
system_test2.txt AC 187 ms
27,024 KB
system_test3.txt AC 227 ms
27,180 KB
system_test4.txt AC 285 ms
34,740 KB
system_test5.txt AC 350 ms
35,520 KB
system_test6.txt AC 232 ms
29,424 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