๐ฆ ๋ฑ์ฐ์ฝ์ค ์ ํ๊ธฐ
1. ๋ฌธ์ ๋งํฌ
2. ์ฝ๋
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from itertools import product
def solution(k, n, reqs):
INF = 2000000000
def solution(n, paths, gates, summits):
graph = []
for i in range(n + 1):
graph.append([])
summits.sort()
for i, j, w in paths:
graph[i].append([j, w])
graph[j].append([i, w])
intensity = [INF] * (n + 1)
result = [0, INF]
q = []
for gate in gates:
q.append([0, gate])
intensity[gate] = 0
while q:
current_intensity, current = q.pop(0)
# ์ฐ๋ด์ฐ๋ฆฌ ๋๋ intensity ์ ์ต์๋ฅผ ์ด๊ณผํ๋ฉด ํ์ ์ข
๋ฃ
if current in summits or current_intensity > intensity[current]:
continue
return result
- ์ ํ์ฑ
3. ํด์ค
์ฌ๋์ ํ์
This post is licensed under CC BY 4.0 by the author.