結果
問題 | No.179 塗り分け |
ユーザー | komkomh |
提出日時 | 2019-04-25 17:12:16 |
言語 | Kotlin (1.9.23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,430 bytes |
コンパイル時間 | 14,502 ms |
コンパイル使用メモリ | 447,928 KB |
実行使用メモリ | 100,804 KB |
最終ジャッジ日時 | 2024-04-30 20:25:02 |
合計ジャッジ時間 | 22,067 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 345 ms
63,804 KB |
testcase_01 | AC | 325 ms
95,244 KB |
testcase_02 | AC | 595 ms
99,796 KB |
testcase_03 | WA | - |
testcase_04 | AC | 712 ms
92,668 KB |
testcase_05 | AC | 328 ms
57,144 KB |
testcase_06 | TLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
ソースコード
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) } } // blacks.forEach { println(it) } // println("----------") if (blacks.size % 2 != 0) { println("NO") return } val redSize = blacks.size / 2 fun canPaint(vararg redIndexes: Int): Boolean { return when (redIndexes.size >= redSize) { true -> { val redMasus = redIndexes.map { blacks[it] } val blueMasus = blacks.filter { !redMasus.contains(it) } for (i in 0 until h) { for (j in 0 until w) { if (i == 0 && j == 0) { continue; } val movedReds = redMasus.map { Pair(it.first + i, it.second + j) } if (movedReds == blueMasus) { return true } } } return false } false -> (redIndexes.last() until redSize).map { canPaint(*redIndexes, it) }.any() } } when (canPaint(1)) { true -> println("YES") false -> println("NO") } }