백준 1504번 : 특정한 최단 경로 (Python)
출처 : https://www.acmicpc.net/problem/1504 import heapq # import sys # input = sys.stdin.readline n, e = map(int, input().split()) graph = [[] for _ in range(n + 1)] for _ in range(e) : a, b, c = map(int, input().split()) graph[a].append((b, c)) graph[b].append((a, c)) # graph = [[], # [(2, 3), (3, 5), (4, 4)], # [(1, 3), (3, 3), (4, 5)], # [(2, 3), (4, 1), (1, 5)], # [(3, 1), (2, 5), (1, 4)]] v1..
2023. 1. 2.
백준 15649, 15650 : N과 M (1), (2) (Python)
N과 M (1) 출처 : https://www.acmicpc.net/problem/15649 # 순열 n, m = map(int, input().split()) sol = list() visited = [0] * (n+1) def permute(n, m) : if len(sol) == m : print(*sol) return for i in range(1, n+1) : if visited[i] == 0 : sol.append(i) visited[i] = 1 permute(n, m) sol.pop() visited[i] = 0 permute(n, m) N과 M (2) 출처 : https://www.acmicpc.net/problem/156450 # 조합 n, m = map(int, input().split..
2022. 12. 26.