結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-27 11:16:42 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 372 ms / 3,000 ms |
| コード長 | 1,219 bytes |
| コンパイル時間 | 15,744 ms |
| コンパイル使用メモリ | 447,816 KB |
| 実行使用メモリ | 57,380 KB |
| 最終ジャッジ日時 | 2024-07-23 15:18:50 |
| 合計ジャッジ時間 | 32,381 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
fun main() {
val (height, width) = readLine()!!.trim().split(' ').map(String::toInt)
val square = Array(height){readLine()!!.trim()}
val type = Array(height){IntArray(width){-1} }
val blackCell = (0 until height).flatMap{h -> (0 until width).filter{w -> square[h][w] == '#'}.map{w -> h to w}}
if (blackCell.size < 2) {
println("NO")
return
}
var hasPair = true
outer@for (dh in 0 until height) {
for (dw in -width + 1 until width) {
if (dh == 0 && dw == 0) continue
val count = (dh * width * 2) + dw + width
hasPair = true
for ((h, w) in blackCell) {
if (type[h][w] >= count) continue
type[h][w] = count
if (h + dh !in 0 until height || w + dw !in 0 until width) {
hasPair = false
break
}
if (square[h + dh][w + dw] != '#') {
hasPair = false
break
}
type[h + dh][w + dw] = count
}
if (hasPair) {
break@outer
}
}
}
println(if (hasPair) "YES" else "NO")
}