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 dfs(_ i: Int, _ j: Int, _ grid: inout [[Bool]], _ H: Int, _ W: Int) -> Int{ var frontier: [(Int, Int)] = [] frontier.append((i, j)) while !frontier.isEmpty { let (h, w) = frontier.popLast()! grid[h][w] = false for (y, x) in [(-1, 0),(0, 1),(1, 0),(0, -1)] { let sucY = h+y let sucX = w+x if sucY < 0 || sucY >= H || sucX < 0 || sucX >= W || !grid[sucY][sucX] { continue } frontier.append((sucY, sucX)) } } return 1 } func main() { let (H, W) = readInt2() var A = readLines(H) var ans = 0 for i in 0..