結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-25 17:12:16 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,430 bytes |
| 記録 | |
| コンパイル時間 | 13,437 ms |
| コンパイル使用メモリ | 446,988 KB |
| 実行使用メモリ | 157,896 KB |
| 最終ジャッジ日時 | 2024-11-20 18:07:35 |
| 合計ジャッジ時間 | 116,587 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 WA * 1 |
| other | AC * 5 WA * 10 RE * 2 TLE * 23 |
ソースコード
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")
}
}