func readInt2() -> (Int, Int) { let l = readLine()!.split(separator: " ").map{Int($0)!} return (l[0], l[1]) } func readLines(_ n: Int) -> [[Bool]] { return (0.. [Bool] in return readLine()!.split(separator: " ").map{$0 == "1"} } } func main() { let (H, W) = readInt2() var A = readLines(H) let dirc = [(-1, 0),(0, 1),(1, 0),(0, -1)] var ans = 0 for i in 0..= H || sucX < 0 || sucX >= W || !A[sucY][sucX] { continue } frontier.append((sucY, sucX)) } } } } print(ans) } main()