알고리즘5 [Python] 백준 1948번 - 임계경로 문제백준 1948번최종 코드import sysfrom collections import dequeinput = sys.stdin.readlinen = int(input())m = int(input())routes = [[] for _ in range(n + 1)]degree = [0] * (n + 1)reversed_routes = [[] for _ in range(n + 1)]max_time = [0] * (n + 1)for _ in range(m): s, e, t = map(int, input().split()) routes[s].append((e, t)) degree[e] += 1 reversed_routes[e].append((s, t))start, end = map(int,.. 2024. 5. 15. [Python] 백준 1516번 - 게임 개발 문제백준 1516번최종 코드import sysfrom collections import dequeinput = sys.stdin.readlineN = int(input())times = [0] * (N + 1)degree = [0] * (N + 1)buildings = [[] for _ in range(N + 1)]result = [0] * (N + 1)for i in range(1, N + 1): line = list(map(int, input().split())) for j in range(len(line)): if line[j] == -1: break if j == 0: times[i] = line[j] .. 2024. 5. 8. [Python] 백준 1976번 - 여행 가자(2) 문제백준 1976번최종 코드import sysinput = sys.stdin.readlinen = int(input())m = int(input())L = [i for i in range(n + 1)]def union(a, b): if L[a] != a: a = find(a) if L[b] != b: b = find(b) if a != b: L[b] = adef find(a): if L[a] == a: return a root = find(L[a]) L[a] = root return rootfor i in range(1, n + 1): temp = [0] + list(map(int, input().split()).. 2024. 5. 6. [Python] 백준 1043번 - 거짓말 문제백준 1043번최종 코드import sysinput = sys.stdin.readlinen, m = map(int, input().split())truth = list(map(int, input().split()))people = [i for i in range(n + 1)]parties = []def union(a, b): if people[a] != a: a = find(a) if people[b] != b: b = find(b) if a != b: people[b] = adef find(a): if people[a] == a: return a root = find(people[a]) people[a] = root .. 2024. 5. 6. 이전 1 2 다음