diff --git a/dohyeondol1/README.md b/dohyeondol1/README.md index 26f1ff5..5821133 100644 --- a/dohyeondol1/README.md +++ b/dohyeondol1/README.md @@ -22,3 +22,6 @@ | 18차시 | 2025.07.04 | 기하학 | [Water Testing](https://www.acmicpc.net/problem/16057)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/70| | 19차시 | 2025.07.09 | 그래프 이론 | [최소 스패닝 트리](https://www.acmicpc.net/problem/1197)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/76| | 20차시 | 2025.07.10 | 문자열 | [접두사](https://www.acmicpc.net/problem/1141)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/78| + | 21차시 | 2025.07.14 | 그래프 이론 | [석고 모형 만들기](https://www.acmicpc.net/problem/32031)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/81| + | 22차시 | 2025.07.19 | 그리디 알고리즘 | [대회 개최](https://www.acmicpc.net/problem/12915)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/87| + | 23차시 | 2025.08.03 | 그래프 이론 | [플로이드](https://www.acmicpc.net/problem/11404)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/93| \ No newline at end of file diff --git "a/dohyeondol1/\352\267\270\353\236\230\355\224\204 \354\235\264\353\241\240/23-dohyeondol1.cpp" "b/dohyeondol1/\352\267\270\353\236\230\355\224\204 \354\235\264\353\241\240/23-dohyeondol1.cpp" new file mode 100644 index 0000000..1b82ada --- /dev/null +++ "b/dohyeondol1/\352\267\270\353\236\230\355\224\204 \354\235\264\353\241\240/23-dohyeondol1.cpp" @@ -0,0 +1,46 @@ +#include +#include +#include +using namespace std; + +const int INF = 1e9; + +int main() { + cin.tie(nullptr)->sync_with_stdio(false); + + int n, m; + cin >> n >> m; + vector> dist(n+1, vector(n+1, INF)); + for(int i = 1; i <= n; i++) + dist[i][i] = 0; + + for(int i = 0; i < m; i++) { + int a, b, c; + cin >> a >> b >> c; + dist[a][b] = min(dist[a][b], c); + } + + for(int k = 1; k <= n; k++) { + for(int i = 1; i <= n; i++) { + for(int j = 1; j <= n; j++) { + if(dist[i][k] != INF && dist[k][j] != INF) { + dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); + } + } + } + } + + for(int i = 1; i <= n; i++) { + for(int j = 1; j <= n; j++) { + if(dist[i][j] == INF) { + cout << 0 << " "; + } + else { + cout << dist[i][j] << " "; + } + } + cout << '\n'; + } + + return 0; +} \ No newline at end of file