diff --git a/code_study/Baekjoon/swift/11404.swift b/code_study/Baekjoon/swift/11404.swift new file mode 100644 index 0000000..26853ed --- /dev/null +++ b/code_study/Baekjoon/swift/11404.swift @@ -0,0 +1,42 @@ +let inf = 100000001 + +if let n = Int(readLine() ?? ""), let m = Int(readLine() ?? "") { + var cost: [[Int]] = Array(repeating: Array(repeating: inf, count: n+1), count: n+1) + + for i in 1...n { + cost[i][i] = 0 + } + + for _ in 0.. t -> e + for t in 1...n { + for s in 1...n { + for e in 1...n { + cost[s][e] = min(cost[s][e], cost[s][t] + cost[t][e]) + } + } + } + + for i in 1...n { + for j in 1...n { + if cost[i][j] == inf { + cost[i][j] = 0 + } + print(Int(cost[i][j]), terminator: " ") + } + print() + } +} +