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/1325
💬 Idea
💬 풀이
import Foundation func solution1325() { let MN = readLine()!.split(separator: " ").map({ Int($0)! }) var graph: [Int: [Int]] = [:] for _ in 1...MN[1] { let nodes = readLine()!.split(separator: " ").map({ Int($0)! }) if graph[nodes[1]] == nil { graph[nodes[1]] = [nodes[0]] } else { graph[nodes[1]]?.append(nodes[0]) } } func dfs(graph: [Int: [Int]], start: Int, visited: [Int]) -> [Int] { var visited = visited if let nodes = graph[start] { for i in nodes { if !visited.contains(i) { visited.append(i) visited = dfs(graph: graph, start: i, visited: visited) } } } return visited } var hackingCountArr: [Int] = [Int](repeating: 0, count: MN[0] + 1) for i in graph.keys { let res = dfs(graph: graph, start: i, visited: []).count hackingCountArr[i] = res } let maxCnt = hackingCountArr.max() for (idx, i) in hackingCountArr.enumerated() { if i == maxCnt { print(idx) } } }
The text was updated successfully, but these errors were encountered:
#172 - 효율적인 해킹 문제 풀이
5fd649b
hwangJi-dev
No branches or pull requests
💬 문제
https://www.acmicpc.net/problem/1325
💬 Idea
💬 풀이
The text was updated successfully, but these errors were encountered: