π λ¬Έμ
π§ μμ΄λμ΄
κ²½μ°μμ - Backtracking κ°λ₯ μ¬λΆ
λͺ¨λ CCTVκ° λμλ¨λΆ 90λλ‘λ§ νμ κ°λ₯νλ€.
CCTV μ’ λ₯λ³λ‘ λ€λ₯Έ κ°μ μμμ κ°λλ‘νλ νμ νμλ λ€μκ³Ό κ°λ€.
1λ² : 4ν
2λ²: 2ν
3λ²: 4ν
4λ²: 4ν
5λ²: 1ν
μ΅λ CCTV κ°μκ° 8κ°λ‘ μ νλμ΄ μμΌλ―λ‘ κ°μ₯ κ²½μ°μμκ° λ§μ 4ν κΈ°μ€
$$ 4^8\;=2^{16}\ $$
μ½ 6λ§ 4μ²νλ―λ‘ Backtracking μΌλ‘ λͺ¨λ κ²½μ°μ μλ₯Ό λ°μ Έλ³΄λ©΄ λκ² λ€.
μ 체 νΉμ°μ μλ₯Ό μ΄λ»κ² ννν΄μΌν κΉ
λͺ¨λ λ°°μ΄μ λν μ‘°ν©μ΄ νμνλ€.
μ΄κ² μ’ λΉ‘μΉλλ°..
κ° CCTV μ€μΉ μ§μ μΌλ‘λΆν°μ λ°©ν₯ μμλν λͺ¨λ μ‘°ν©μ 미리 keep ν΄λ¬μ ꡬννλ€.
2μ°¨μ λ°°μ΄μμ λͺ¨λ λ°°μ΄μ μμ λν μ‘°ν©μ ꡬνλ μ½λκ° GeeksForGeeks μ μκ°λμ΄μλ€.
β οΈ CCTVκ° μλ μ£μ§μΌμ΄μ€
CCTVκ° μ€μΉλμ§ μλ μΌμ΄μ€λ ꡬν΄μΌνλ€.
β οΈ ν λ² μ€μνλ©΄ κ°λ§νλ€.
μ΄λ° ꡬνλ₯μ λ¬Έμ λ λλ²κΉ νκΈ°κ° μ λ§ μ΄λ ΅λ€.
ν μ€νΈ μΌμ΄μ€λ₯Ό μ€μ€λ‘ λ§λ€κΈ°λ μ΄λ ΅λ€. κ·Έλ₯ μ΅κ³ μ μ§μ€λ ₯μΌλ‘ νλνλ μ¨ μ μ μ μμμ ꡬνν΄μΌνλ€...
π Kotlin Code
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import kotlin.math.min
// key: cctv μ’ν, value: kind
data class CCTV(val X: Int, val Y: Int, val type: Int) {
}
// key: cctv type, value: rotate kind
private val cctvMap = mapOf<Int, Array<String>>(
1 to arrayOf("up", "right", "down", "left"),
2 to arrayOf("horizontal", "vertical"),
3 to arrayOf("upRight", "rightDown", "downLeft", "leftUp"),
4 to arrayOf("leftUpRight", "upRightDown", "rightDownLeft", "downLeftUp"),
5 to arrayOf("cardinalDirection")
)
// # λμ -1 λ‘ λμΉνλ©΄λ¨.
private fun bfs(cctvPoint: CCTV, direction: String, map: Array<IntArray>) {
// μ μ¬κΈ°μ νμ
μ μ΄μΌλλμ§ cctvMap μ¬μ©ν΄μ νμ
λ³λ‘ CCTV κ°μꡬμ λ§νΉνλ©΄λλλ°
// μ΄ 14κ°μ§ cctv κ°μ λͺ¨λ λ리면λ λ―
val (startRowIdx, startColIdx) = cctvPoint
var rightColIdx = startColIdx + 1
var leftColIdx = startColIdx - 1
var upRowIdx = startRowIdx - 1
var downRowIdx = startRowIdx + 1
when(direction) {
// 1λ²
"up"-> {
while (upRowIdx >= 0 && map[upRowIdx][startColIdx] != 6) map[upRowIdx--][startColIdx] = -1
}
"right"-> {
while (rightColIdx < map[0].size && map[startRowIdx][rightColIdx] != 6) map[startRowIdx][rightColIdx++] = -1
}
"down"-> {
while (downRowIdx < map.size && map[downRowIdx][startColIdx] != 6) map[downRowIdx++][startColIdx] = -1
}
"left"-> {
while (leftColIdx >= 0 && map[startRowIdx][leftColIdx] != 6) map[startRowIdx][leftColIdx--] = -1
}
// 2λ²
"horizontal"-> {
while (rightColIdx < map[startRowIdx].size && map[startRowIdx][rightColIdx] != 6) map[startRowIdx][rightColIdx++] = -1
while (leftColIdx >= 0 && map[startRowIdx][leftColIdx] != 6) map[startRowIdx][leftColIdx--] = -1
}
"vertical"-> {
while (upRowIdx >= 0 && map[upRowIdx][startColIdx] != 6) map[upRowIdx--][startColIdx] = -1
while (downRowIdx < map.size && map[downRowIdx][startColIdx] != 6) map[downRowIdx++][startColIdx] = -1
}
// 3λ²
"upRight"-> {
while (upRowIdx >= 0 && map[upRowIdx][startColIdx] != 6) map[upRowIdx--][startColIdx] = -1
while (rightColIdx < map[startRowIdx].size && map[startRowIdx][rightColIdx] != 6) map[startRowIdx][rightColIdx++] = -1
}
"rightDown"-> {
while (rightColIdx < map[startRowIdx].size && map[startRowIdx][rightColIdx] != 6) map[startRowIdx][rightColIdx++] = -1
while (downRowIdx < map.size && map[downRowIdx][startColIdx] != 6) map[downRowIdx++][startColIdx] = -1
}
"downLeft"-> {
while (downRowIdx < map.size && map[downRowIdx][startColIdx] != 6) map[downRowIdx++][startColIdx] = -1
while (leftColIdx >= 0 && map[startRowIdx][leftColIdx] != 6) map[startRowIdx][leftColIdx--] = -1
}
"leftUp"-> {
while (leftColIdx >= 0 && map[startRowIdx][leftColIdx] != 6) map[startRowIdx][leftColIdx--] = -1
while (upRowIdx >= 0 && map[upRowIdx][startColIdx] != 6) map[upRowIdx--][startColIdx] = -1
}
// 4λ²
"leftUpRight"->{
while (leftColIdx >= 0 && map[startRowIdx][leftColIdx] != 6) map[startRowIdx][leftColIdx--] = -1
while (upRowIdx >= 0 && map[upRowIdx][startColIdx] != 6) map[upRowIdx--][startColIdx] = -1
while (rightColIdx < map[startRowIdx].size && map[startRowIdx][rightColIdx] != 6) map[startRowIdx][rightColIdx++] = -1
}
"upRightDown"-> {
while (upRowIdx >= 0 && map[upRowIdx][startColIdx] != 6) map[upRowIdx--][startColIdx] = -1
while (rightColIdx < map[startRowIdx].size && map[startRowIdx][rightColIdx] != 6) map[startRowIdx][rightColIdx++] = -1
while (downRowIdx < map.size && map[downRowIdx][startColIdx] != 6) map[downRowIdx++][startColIdx] = -1
}
"rightDownLeft"-> {
while (rightColIdx < map[startRowIdx].size && map[startRowIdx][rightColIdx] != 6) map[startRowIdx][rightColIdx++] = -1
while (downRowIdx < map.size && map[downRowIdx][startColIdx] != 6) map[downRowIdx++][startColIdx] = -1
while (leftColIdx >= 0 && map[startRowIdx][leftColIdx] != 6) map[startRowIdx][leftColIdx--] = -1
}
"downLeftUp"-> {
while (downRowIdx < map.size && map[downRowIdx][startColIdx] != 6) map[downRowIdx++][startColIdx] = -1
while (leftColIdx >= 0 && map[startRowIdx][leftColIdx] != 6) map[startRowIdx][leftColIdx--] = -1
while (upRowIdx >= 0 && map[upRowIdx][startColIdx] != 6) map[upRowIdx--][startColIdx] = -1
}
// 5λ²
"cardinalDirection"-> {
// λμλ¨λΆ λ€
while (upRowIdx >= 0 && map[upRowIdx][startColIdx] != 6) map[upRowIdx--][startColIdx] = -1
while (rightColIdx < map[startRowIdx].size && map[startRowIdx][rightColIdx] != 6) map[startRowIdx][rightColIdx++] = -1
while (downRowIdx < map.size && map[downRowIdx][startColIdx] != 6) map[downRowIdx++][startColIdx] = -1
while (leftColIdx >= 0 && map[startRowIdx][leftColIdx] != 6) map[startRowIdx][leftColIdx--] = -1
}
}
}
fun main() {
val bufferedReader = BufferedReader(InputStreamReader(System.`in`))
val (rowSize, colSize) = bufferedReader.readLine().split(" ").map(String::toInt)
val map: Array<IntArray> = Array(rowSize){
bufferedReader.readLine().split(" ").map(String::toInt).toIntArray()
}
val stringBuilder = StringBuilder()
val cctvPoints = LinkedList<CCTV>()
for (row in map.indices) {
for (col in map[row].indices) {
if (map[row][col] in 1..5) cctvPoints.add(CCTV(row, col, map[row][col]))
}
}
// CCTV κ° μλ μΌμ΄μ€
if (cctvPoints.size == 0) {
var zeroCnt = 0
for (arr in map) {
zeroCnt += arr.count { it == 0 }
}
print(zeroCnt)
return
}
// μ¬κΈ°μ λͺ¨λ rotate λ°©ν₯μ λν μ΄ ν¬μΈνΈ μμμ λ€μ kind array μ‘°ν©λ§ λλ©΄ λͺ¨λ κ² ν΄κ²°λ¨.
// (point index μ ν΄λΉνλ λ°©ν₯ λͺ¨λ μ‘°ν©μ΄ μμ±λκΈ° λλ¬Έμ ν μΈμ΄ν΄ λλ λλ§λ€ μ‘°μ§λ©΄λ¨.)
// cctv λͺ¨λ νμ
μ λν νμ μ 보 μ‘°ν©λ§ κ°μ§κ³ κ·Έμ λ€μ λν΄ λͺ¨λ DFS λ리면 λ¨.
val types = cctvPoints.map { cctvMap[it.type]!! }
// direction μ λͺ¨λ μ‘°ν© set κ°μ
val directions = LinkedList<LinkedList<String>>()
// λͺ¨λ μ‘°ν© κ΅¬νκΈ°.
val indices = IntArray(types.size)
var directionIdx = 0
while (true) {
directions.add(LinkedList<String>())
for (i in types.indices) {
stringBuilder.append("${types[i][indices[i]]} ")
directions[directionIdx].add(types[i][indices[i]])
}
directionIdx++
stringBuilder.appendLine()
var next = types.size - 1
while (next >= 0 && indices[next] + 1 >= types[next].size) next--
if (next < 0 ) break
indices[next]++
for (i in next + 1 until types.size) indices[i] = 0
}
var tempMap = map.map { it.clone() }.toTypedArray()
var answer = colSize * rowSize
var zeroCnt = 0
for (directionArr in directions) {
directionArr.forEachIndexed { idx, direction ->
bfs(cctvPoints[idx], direction, tempMap)
}
// count 0 κ°μ in tempMap
for (arr in tempMap) {
zeroCnt += arr.count { it == 0 }
}
answer = min(answer, zeroCnt)
zeroCnt = 0
// reset tempMap by map
tempMap = map.map { it.clone() }.toTypedArray()
}
print(answer)
}
βοΈ Refactoring
2μ°¨μ λ°°μ΄μ λ°©ν₯μμ λ΄μ λͺ¨λ μμ΄μ ꡬνλ Backtracking λ°©μλ³΄λ€ λ κ°λ¨ν λ°©λ²μ μμκΉ?
κ° μ리μ μ¬ κ°μ΄ λͺ¨λ μ«μμ΄λ©° κ³ μ λ²μμΌ λ
Nμ§λ²μ μ¬μ©νλ©΄ Backtracking λ³΄λ€ μ½κ² λͺ¨λ κ²½μ°μ μλ₯Ό ννν μ μλ€.
λͺ¨λ κ²½μ°μ μ (CCTV λ³ λ°©ν₯ 맀μΉ) μ λν΄ κ°μ μμμ -1λ‘ μμΉ νλ ν¨μλ₯Ό μμ±νκ³
μ¬κ°μ§λμ μ΅μ κ°μ ꡬν΄λ³΄μ
π Kotlin Code
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import kotlin.math.min
// 4μ§λ²μμ ννλ μ«μκ° μλ―Ένλ λ°©ν₯
enum class Direction {
SOUTH, // 0
EAST, // 1
NORTH, // 2
WEST // 3
}
private val dx = intArrayOf(1, 0, -1, 0)
private val dy = intArrayOf(0, 1, 0, -1)
data class CCTV(val X: Int, val Y: Int, val type: Int) {
}
private fun isOutOfBoundary(row: Int, col: Int, map: Array<IntArray>) : Boolean{
return row < 0 || col < 0 || row >= map.size || col >= map[0].size
}
// ν λ°©ν₯μΌλ‘λ§ μμΉ
// μ΄λ―Έ νΉμ CCTVμ λ°©ν₯μ κ²°μ λ μνλ‘ μμΉ λ§ μ‘°μ§κ² νκΈ°.
private fun surveilFromCCTV(startRow: Int, startCol: Int, direction: Int, map: Array<IntArray>) {
val realDirection = direction % 4
var nextRow = startRow
var nextCol = startCol
while (true) {
// μ€λ‘μ§ λ¨λλΆμ μ€ 1κ°λ§ κ°μ§
nextRow += dx[realDirection]
nextCol += dy[realDirection]
// λ²μλ₯Ό λ²μ΄λ¬κ±°λ λ²½μ λ§λλ©΄ μμΉ μ’
λ£
if (isOutOfBoundary(nextRow, nextCol, map) || map[nextRow][nextCol] == 6) return
// CCTV κ±°λ μ΄λ―Έ κ°μκ° λκ³ μλ μ§μμ΄λ©΄ λ€μμΌλ‘ ν΅κ³Ό (μ¬μ€ μ΄ μ½λλ μμ΄λ λ¨)
if (map[nextRow][nextCol] != 0) continue
map[nextRow][nextCol] = -1
}
}
fun main() {
val bufferedReader = BufferedReader(InputStreamReader(System.`in`))
val (rowSize, colSize) = bufferedReader.readLine().split(" ").map(String::toInt)
val originalMap: Array<IntArray> = Array(rowSize){
bufferedReader.readLine().split(" ").map(String::toInt).toIntArray()
}
val cctvPoints = LinkedList<CCTV>()
var answer = 0
// (1) 1st cctv point λ£κ³
for (row in originalMap.indices) {
for (col in originalMap[row].indices) {
if (originalMap[row][col] in 1 .. 5) cctvPoints.add(CCTV(row, col, originalMap[row][col]))
// νμ΄μ μνμμ 0μ κ°μλ 미리 ꡬν΄λμΌν¨. (CCTV κ° 1κ° μ΄μ μ€μΉλλ€λ 보μ₯μ΄ μμ.)
else if (originalMap[row][col] == 0) answer++
}
}
// (2) λͺ¨λ CCTV-λ°©ν₯ μμ μμ΄ κ²½μ°μ μ ꡬνκΈ°
// μ΄ κ²½μ°μ μ == μ리 μ (4) ^ cctv κ°μ == 2 ^ (2 * cctv κ°μ)
val maxPosCnt = 1 shl (2 * cctvPoints.size)
for (num in 0 until maxPosCnt) {
// 맀 case λ§λ€ μμ μ§λλ₯Ό μ΄κΈ°ν ν΄μΌν¨
val tempMap = Array(originalMap.size){ idx-> originalMap[idx].copyOf()}
var nextNum = num
for (cctv in cctvPoints) {
// κ° cctv λ³ λ°©ν₯ κ²°μ (첫λ²μ§Έ μ리)
val curDirection = nextNum % 4
// λ€μλ² λ°©ν₯μ κ²°μ ν μ μκ² μ΄λ―Έ μ¬μ©ν 첫λ²μ§Έ μ리 μ κ±°
nextNum /= 4
// λ°©ν₯μ΄ μ ν΄μ§ μνλ©΄ CCTV μ’
λ₯μ λ°λΌμ κ° λ°©ν₯μ μμΉ μ λλ €μΌν¨.
// λͺ¨λ λ°©ν₯μ 1κ°μ λ°©ν₯λ§ κ°μ§. (νμ
λ³λ‘ μ¬κΈ°μ λΆκΈ°)
val (row, col, type) = cctv
when (type) {
// λ¨λλΆμ μ€ 1λ°©ν₯
1 -> surveilFromCCTV(row, col, curDirection, tempMap)
2 -> {
// 무쑰건 μν || μμ§ 2λ°©ν₯
surveilFromCCTV(row, col, curDirection, tempMap)
surveilFromCCTV(row, col, curDirection + 2, tempMap)
}
3 -> {
// 2λ°©ν₯ γ±μ λͺ¨μ
surveilFromCCTV(row, col, curDirection, tempMap)
surveilFromCCTV(row, col, curDirection + 1, tempMap)
}
4 -> {
// 3λ°©ν₯ γ
μ λͺ¨μ
surveilFromCCTV(row, col, curDirection, tempMap)
surveilFromCCTV(row, col, curDirection + 1, tempMap)
surveilFromCCTV(row, col, curDirection + 2, tempMap)
}
5 -> {
// 4λ°©ν₯ λͺ¨λ
surveilFromCCTV(row, col, curDirection, tempMap)
surveilFromCCTV(row, col, curDirection + 1, tempMap)
surveilFromCCTV(row, col, curDirection + 2, tempMap)
surveilFromCCTV(row, col, curDirection + 3, tempMap)
}
}
}
// (3) (1, 2) μμ ꡬν μμ΄μ νλμ© λ리며 case 1κ° λ³λ‘ μ¬κ°μ§λ ꡬνκΈ°
var zeroCnt = 0
for (row in tempMap) {
for (value in row) if (value == 0) zeroCnt++
}
// (4) (3) μμ ꡬν μ¬κ°μ§λ κ°μ μ€ μ΅μ κ°μ μ λ΅μΌλ‘ μ²λ¦¬.
answer = min(answer, zeroCnt)
}
print(answer)
}
π Kotlin Code
5λ² cctv λ λ°©ν₯μ΄ μ΄μ°¨νΌ 0 νλλ‘λ§ κ²°μ λλ λμλ¨λΆμ λͺ¨λ κ° κ²μ΄κ³
2λ² cctvλ (0,2), (1,3) λ± μμ§/μνμ΄λ (2,4), (3,5) λ κ°μ λ°©ν₯μ΄λ―λ‘ continue λ‘ μ‘°κΈμ΄λλ§ μ΅μ νκ° κ°λ₯νλ€.
λ€μ μ½λλ 2λ²μμ direction μ΄ 2 μ΄μμ΄κ±°λ
5λ²μμ direction μ΄ 0μ΄ μλ λ κ°μλ₯Ό μ€ν΅νμ¬ 0μ μ΅λ κ°―μ(μ΅μ μ ν΄) κ° μλμΌμ΄μ€λ‘ μ‘°κΈμ΄λΌλ μ°μ°λμ μ€μ΄λ μ½λλ€.
(μ€μ λ‘ ν΄λΉ μΌμ΄μ€μ λͺ¨λ CCTV κ°μλ₯Ό μ€ν΅νλκ² μλλΌ 2λ², 5λ² CCTVμ μ§μ λ λ°©ν₯ μ΄μΈμλ κ°μλ₯Ό μ€ν΅νμ¬ μ΅μ μ ν΄κ° μ λ μλλλ‘ νλ λ°©μ)
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import kotlin.math.min
// λ¨ λ λΆ μ
private val dx = intArrayOf(-1, 0, 1, 0)
private val dy = intArrayOf(0, 1, 0, -1)
fun isOutOfBoundMap(rowIdx: Int, colIdx: Int, tempMap: Array<IntArray>) : Boolean {
return rowIdx < 0 || colIdx < 0 || rowIdx >= tempMap.size || colIdx >= tempMap[0].size
}
// κ°μ μμ
// μ ν΄μ§ cctv μ’νλ‘λΆν° μ ν΄μ§ direction: 0 ~ 4 μΌλ‘ μ€κ³§ μ΄λ
fun surveilByCCTV(row: Int, col: Int, direction: Int, tempMap: Array<IntArray>) {
val curDirection = direction % 4
var nextRow = row + dx[curDirection]
var nextCol = col + dy[curDirection]
while (!isOutOfBoundMap(nextRow, nextCol, tempMap)) {
// λ²½ λ§λλ©΄ μμΉ μ’
λ£
if (tempMap[nextRow][nextCol] == 6) return
else if (tempMap[nextRow][nextCol] == 0) tempMap[nextRow][nextCol] = -1
// μ ν΄μ§ λ°©ν₯μΌλ‘ ν μΉΈμ© μ΄λ
nextRow += dx[curDirection]
nextCol += dy[curDirection]
}
}
fun getCountOfBlindSpot(tempMap: Array<IntArray>): Int {
var zeroCnt = 0
for (row in tempMap.indices) {
for (col in tempMap[row].indices) {
if (tempMap[row][col] == 0) zeroCnt++
}
}
return zeroCnt
}
fun main() {
val bufferedReader = BufferedReader(InputStreamReader(System.`in`))
val (N, M) = bufferedReader.readLine().split(" ").map(String::toInt)
val map = Array(N){idx->
bufferedReader.readLine().split(" ").map(String::toInt).toIntArray()
}
val cctvPoints = LinkedList<IntArray>()
var answer = 0
// 1. μλ³Έ λ°°μ΄ μννλ©° cctv point keep.
// 0 κ°μλ answer νλ³΄λ‘ keep (cctv λ―Έμ€μΉ μΌμ΄μ€κ° μ‘΄μ¬ν¨)
for (row in map.indices) {
for (col in map[row].indices) {
if (map[row][col] in 1 .. 5) cctvPoints.add(intArrayOf(row, col))
else if (map[row][col] == 0) answer++
}
}
// cctv - λ°©ν₯ μ μ΄ μμ΄ κ²½μ°μ μ == 4^CCTV μ == 2 ^ (2 * CCTV μ)
val numOfCases = 1 shl (2 * cctvPoints.size)
for (num in 0 until numOfCases) {
val tempMap = Array(map.size){idx -> map[idx].copyOf()}
var nextNum = num
for (point in cctvPoints) {
// num μ cctv μλ§νΌ μ리μλ₯Ό κ°μ§.
// λ°λΌμ cctv μλ§νΌ λλ μ Έμ λμ리κΉμ§ λ€ κ²μ¬ν΄μΌν¨.
// κ° μΌμ΄μ€λ₯Ό μννλ©° μμ 맡μ μμΉ
val curDirection = nextNum % 4
val (row, col) = point
// μμ μ§λμ μμΉ
// μΉ΄λ©λΌ μ’
λ₯λ§λ€ μμΉ λ°©λ²μ΄ λ€λ¦.
when (map[row][col]) {
1 -> {
surveilByCCTV(row, col, curDirection, tempMap)
}
2 -> {
// λ°©ν₯μμ΄ (0-2) μμ§, (1-3) μν λ§ μλ―Έμμ.
// (2-4), (3-5) λ μ΄μ°¨νΌ μ€λ³΅μ΄κΈ° λλ¬Έμ skip
if (curDirection >= 2) continue
surveilByCCTV(row, col, curDirection, tempMap)
surveilByCCTV(row, col, curDirection + 2, tempMap)
}
3 -> {
surveilByCCTV(row, col, curDirection, tempMap)
surveilByCCTV(row, col, curDirection + 1, tempMap)
}
4 -> {
surveilByCCTV(row, col, curDirection, tempMap)
surveilByCCTV(row, col, curDirection + 1, tempMap)
surveilByCCTV(row, col, curDirection + 2, tempMap)
}
5 -> {
// μ΄μ°¨νΌ λͺ¨λ λ°©ν₯μ λν΄ (0,1,2,3) λ€ κ° κ²μ΄λ―λ‘ κ·Έ μ΄μμ μ«μλ μλ―Έ μμ.
if (curDirection != 0) continue
surveilByCCTV(row, col, 0, tempMap)
surveilByCCTV(row, col, 1, tempMap)
surveilByCCTV(row, col, 2, tempMap)
surveilByCCTV(row, col, 3, tempMap)
}
}
nextNum /= 4
}
// ν μΌμ΄μ€μ λν μμΉ μ΄ μ’
λ£λμΌλ©΄ 0μ κ°μλ₯Ό μΉ΄μ΄ν
val zeroCnt = getCountOfBlindSpot(tempMap)
answer = min(answer, zeroCnt)
}
print(answer)
}
π Reference
'Algorithm > Algorithm (λ¬Έμ νμ΄)' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[λ°±μ€] 1504 νΉμ ν μ΅λ¨κ²½λ‘ (0) | 2022.10.07 |
---|---|
[λ°±μ€] 18808 μ€ν°μ»€ λΆμ΄κΈ° (0) | 2022.10.06 |
[λ°±μ€] 2493 ν (0) | 2022.10.03 |
[λ°±μ€] 2217 λ‘ν (0) | 2022.09.28 |
[λ°±μ€] 11779 μ΅μλΉμ© ꡬνκΈ° 2 (0) | 2022.09.23 |