Skip to content

Commit

Permalink
solve(BOJ): G4_1915_가장_큰_정사각형_kt
Browse files Browse the repository at this point in the history
  • Loading branch information
gogumaC committed Jan 6, 2024
1 parent c843506 commit 85430e9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/boj/G4_1915_가장_큰_정사각형.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package boj

class BOJ1915() {
fun solve() {
val (n, m) = readln().split(" ").map { it.toInt() }
val map = Array(n + 1) { IntArray(m + 1) }
var max = 0

for (i in 1..n) {
val input = readln()
for (j in 1..m) {
map[i][j] = input[j - 1].digitToInt()
if (map[i][j] == 1 && max != 1) max = 1
}
}

for (i in 1..n) {
for (j in 1..m) {
if (map[i][j] == 0) continue
map[i][j] = minOf(map[i - 1][j - 1], map[i - 1][j], map[i][j - 1]) + 1
if (map[i][j] > max) max = map[i][j]
}
}

println(max * max)
}
}

fun main() {
BOJ1915().solve()
}

0 comments on commit 85430e9

Please sign in to comment.