다익스트라 13

[백준] 1916 최소비용 구하기 python

www.acmicpc.net/problem/1916 1916번: 최소비용 구하기 첫째 줄에 도시의 개수 N(1 ≤ N ≤ 1,000)이 주어지고 둘째 줄에는 버스의 개수 M(1 ≤ M ≤ 100,000)이 주어진다. 그리고 셋째 줄부터 M+2줄까지 다음과 같은 버스의 정보가 주어진다. 먼저 처음에는 그 www.acmicpc.net import sys input = sys.stdin.readline from heapq import heappop, heappush N = int(input()) M = int(input()) link_arr = [list() for _ in range(N + 1)] for _ in range(M): st, en, we = map(int, input().split()) link..

STUDY/Algorithm 2021.04.29

[백준] 1504 특정한 최단 경로 python

www.acmicpc.net/problem/1504 1504번: 특정한 최단 경로 첫째 줄에 정점의 개수 N과 간선의 개수 E가 주어진다. (2 ≤ N ≤ 800, 0 ≤ E ≤ 200,000) 둘째 줄부터 E개의 줄에 걸쳐서 세 개의 정수 a, b, c가 주어지는데, a번 정점에서 b번 정점까지 양방향 길이 존 www.acmicpc.net import sys input = sys.stdin.readline from heapq import heappop, heappush N, E = map(int, input().split()) link_arr = [list() for _ in range(N + 1)] for _ in range(E): n1, n2, w = map(int, input().split()) ..

STUDY/Algorithm 2021.04.27

[백준] 1753 최단경로 python

www.acmicpc.net/problem/1753 1753번: 최단경로 첫째 줄에 정점의 개수 V와 간선의 개수 E가 주어진다. (1≤V≤20,000, 1≤E≤300,000) 모든 정점에는 1부터 V까지 번호가 매겨져 있다고 가정한다. 둘째 줄에는 시작 정점의 번호 K(1≤K≤V)가 주어진다. www.acmicpc.net import sys from heapq import heappop, heappush input = sys.stdin.readline N, E = map(int, input().split()) K = int(input()) link = [list() for _ in range(N + 1)] for _ in range(E): n1, n2, w = map(int, input().split(..

STUDY/Algorithm 2021.04.22