[Swift][BFS] 백준 17086번 (아기상어2)
요구능력 : BFS 코드설명 : 후기 : 기초적인 BFS문제인것 같다. 아기상어보다 아기상어2 난이도가 훨씬낮다. let nm = readLine()!.split(separator: " ").map{Int(String($0))!} let n = nm[0] let m = nm[1] var arr = [[Int]]() let dx = [-1, 1, 0, 0, -1, 1, 1, -1] let dy = [0, 0, -1, 1, 1, -1, 1, -1] for _ in 0.. idx { let pop = queue[idx] let x = pop.0.0 let y = pop.0.1 let safeDistance = pop.1 idx += 1 if arr[x][y] == 1 { result.append(safeDis..
2022. 1. 28.