Skip to content

Commit b980f1b

Browse files
authored
명환 백준 숙제 (#67)
1 parent 2fbd6e5 commit b980f1b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

mhkim/baekjoon/11265.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
@file 11265.py
3+
@brief 끝나지 않는 파티
4+
@desc 플로이드 워셜
5+
"""
6+
import sys
7+
input = sys.stdin.readline
8+
9+
n, m = map(int, input().split())
10+
parties = []
11+
for i in range(n):
12+
parties.append(list(map(int, input().split())))
13+
14+
15+
def floyd_warshall():
16+
for k in range(n):
17+
for i in range(n):
18+
for j in range(n):
19+
parties[i][j] = min(
20+
parties[i][j], parties[i][k] + parties[k][j])
21+
22+
23+
floyd_warshall()
24+
25+
for i in range(m):
26+
a, b, c = map(int, input().split())
27+
if parties[a-1][b-1] <= c:
28+
print("Enjoy other party")
29+
else:
30+
print("Stay here")

mhkim/baekjoon/1446.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
@file 1446.py
3+
@brief 지름길
4+
@desc 다잌스트라
5+
6+
DP로도 풀 수 있을 것 같음
7+
"""
8+
import sys
9+
import heapq
10+
input = sys.stdin.readline
11+
INF = int(1e9)
12+
13+
n, d = map(int, input().split())
14+
graph = [[] for _ in range(d+1)]
15+
distance = [i for i in range(d+1)]
16+
17+
for _ in range(n):
18+
start, dest, shortcut = map(int, input().split())
19+
if dest <= d:
20+
graph[start].append((dest, shortcut))
21+
22+
for i in range(d+1):
23+
if i > 0:
24+
distance[i] = min(distance[i], distance[i-1]+1)
25+
for j in graph[i]:
26+
if distance[i]+j[1] < distance[j[0]]:
27+
distance[j[0]] = distance[i]+j[1]
28+
29+
print(distance[d])

0 commit comments

Comments
 (0)