結果

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

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
00_sample1.txt AC 201 ms
27,072 KB
00_sample2.txt AC 191 ms
27,004 KB
00_sample3.txt AC 200 ms
27,128 KB
00_sample4.txt AC 200 ms
27,116 KB
00_sample5.txt AC 200 ms
27,188 KB
00_sample6.txt AC 209 ms
27,480 KB
10_hand01.txt AC 282 ms
35,420 KB
10_hand02.txt AC 208 ms
27,528 KB
10_hand03.txt AC 281 ms
31,572 KB
10_hand04.txt AC 292 ms
31,560 KB
10_hand05.txt AC 795 ms
35,852 KB
10_hand06.txt AC 719 ms
36,048 KB
10_hand07.txt AC 1,327 ms
38,092 KB
10_hand08.txt AC 204 ms
27,272 KB
10_hand09.txt AC 207 ms
27,260 KB
10_hand10.txt AC 190 ms
26,988 KB
10_hand11.txt AC 194 ms
27,028 KB
10_hand12.txt AC 208 ms
27,076 KB
10_hand13.txt AC 543 ms
35,688 KB
10_hand14.txt AC 534 ms
35,660 KB
10_hand15.txt AC 220 ms
27,692 KB
10_hand16.txt AC 219 ms
27,592 KB
10_hand17.txt AC 398 ms
35,592 KB
10_hand18.txt AC 424 ms
35,556 KB
10_hand19.txt AC 379 ms
35,648 KB
10_hand20.txt AC 345 ms
35,676 KB
20_random01.txt AC 404 ms
35,708 KB
20_random02.txt AC 586 ms
35,672 KB
20_random03.txt AC 515 ms
35,660 KB
20_random04.txt AC 792 ms
35,748 KB
20_random05.txt AC 682 ms
35,828 KB
20_random06.txt AC 895 ms
35,760 KB
20_random07.txt AC 666 ms
35,888 KB
20_random08.txt AC 900 ms
35,772 KB
20_random09.txt AC 702 ms
35,940 KB
20_random10.txt AC 1,011 ms
35,884 KB
99_system_test1.txt AC 200 ms
27,072 KB
99_system_test2.txt AC 190 ms
27,004 KB
99_system_test3.txt AC 194 ms
27,080 KB
system_test1.txt AC 197 ms
27,156 KB
system_test2.txt AC 190 ms
26,996 KB
system_test3.txt AC 198 ms
27,168 KB
system_test4.txt AC 269 ms
34,704 KB
system_test5.txt AC 359 ms
35,552 KB
system_test6.txt AC 231 ms
29,444 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