일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 11053
- 9095
- Python
- 11057
- 순열
- itertools
- 나머지
- 코틀린
- 매일11시
- expo
- 1260
- 앱
- 6603
- 홈화면
- LCS
- 11054
- 파이썬
- 1182
- Kotlin
- 뒤로가기
- Android
- 안드로이드
- 코테
- 괄호
- permutation
- 11기
- 최소공배수
- lcm
- 백준
- Combination
Archives
- Today
- Total
목록다익스트라 (1)
황소개발자
백준 1753 파이썬 python : 최단경로 @@황소처럼 우직하게@@
다익스트라는 Greedy 와 BFS 를 섞은 느낌이다 BFS에서 대신 q를 쓸 때, min heap q를 사용한다. 그래야 다음으로 가장 짧은 노드를 빠르게 찾을 수 있으니. import sys import heapq inpu = sys.stdin.readline INF = 999999999 def dijkstra(v, start, g): dist = [INF] * (V + 1) dist[start] = 0 q = [] heapq.heappush(q, [0, start]) while q: cost, loc = heapq.heappop(q) for l, c in g[loc]: c += cost if c < dist[l]: dist[l] = c heapq.heappush(q, [c, l]) return di..
백준 문제 풀이
2020. 2. 22. 02:12