結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
rutilicus
|
| 提出日時 | 2020-09-02 21:56:04 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 462 ms / 3,000 ms |
| コード長 | 1,220 bytes |
| コンパイル時間 | 13,548 ms |
| コンパイル使用メモリ | 443,544 KB |
| 実行使用メモリ | 87,868 KB |
| 最終ジャッジ日時 | 2024-07-23 15:19:44 |
| 合計ジャッジ時間 | 31,977 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
コンパイルメッセージ
Main.kt:45:13: warning: 'appendln(String?): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
builder.appendln(if (ok) "YES" else "NO")
^
ソースコード
fun main() {
val builder = StringBuilder()
val (h, w) = readInputLine().split(" ").map { it.toInt() }
val map = Array(h) { readInputLine().toCharArray() }
var ok = false
for (i in -h until h) {
if (ok) {
break
}
for (j in -w until w) {
val tmp = Array(h) { map[it].copyOf() }
var ng = false
for (k in 0 until h) {
if (ng) {
break
}
for (l in 0 until w) {
if (tmp[k][l] == '#') {
tmp[k][l] = 'r'
if (k + i < 0 || k + i >= h || l + j < 0 || l + j >= w || tmp[k + i][l + j] != '#') {
ng = true
break
}
tmp[k + i][l + j] = 'b'
}
}
}
if (!ng) {
ok = true
break
}
}
}
if (!map.any { it.contains('#') }) {
ok = false
}
builder.appendln(if (ok) "YES" else "NO")
print(builder.toString())
}
fun readInputLine(): String {
return readLine()!!
}
rutilicus