We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💬 문제
https://www.acmicpc.net/problem/2606
💬 Idea
💬 풀이
import Foundation func solution2606() -> Int { let computerCount = Int(readLine()!)! let connectCount = Int(readLine()!)! var graph: [String: [String]] = [:] for _ in 0..<connectCount { let connect = readLine()!.split(whereSeparator: { $0 == " " }).map({ String($0) }) let node1 = connect[0] let node2 = connect[1] if graph[node1] == nil { graph[node1] = [node2] } else { graph[node1]?.append(node2) } if graph[node2] == nil { graph[node2] = [node1] } else { graph[node2]?.append(node1) } } let warmVirusComputerArr = dfs(graph, "1") return warmVirusComputerArr.count - 1 } func dfs(_ graph: [String: [String]], _ start: String) -> [String] { var needToVisitStack: [String] = [start] var visitedQueue: [String] = [] while !needToVisitStack.isEmpty { let node = needToVisitStack.removeLast() if visitedQueue.contains(node) { continue } visitedQueue.append(node) needToVisitStack += graph[node] ?? [] } return visitedQueue }
소요시간 : 25분
소요시간
The text was updated successfully, but these errors were encountered:
#166 - 바이러스 문제 풀이
5a34a29
5d95589
hwangJi-dev
No branches or pull requests
💬 문제
https://www.acmicpc.net/problem/2606
💬 Idea
💬 풀이
소요시간
: 25분The text was updated successfully, but these errors were encountered: