본문 바로가기

Problem Solving96

[MST] 1197 최소 스패닝 트리 https://www.acmicpc.net/problem/1197 1197번: 최소 스패닝 트리 첫째 줄에 정점의 개수 V(1 ≤ V ≤ 10,000)와 간선의 개수 E(1 ≤ E ≤ 100,000)가 주어진다. 다음 E개의 줄에는 각 간선에 대한 정보를 나타내는 세 정수 A, B, C가 주어진다. 이는 A번 정점과 B번 정점이 www.acmicpc.net # 2023.01.14 import sys input = sys.stdin.readline import heapq v, e = map(int, input().split()) # 정점, 간선 graph=[[] for _ in range(v+1)] for i in range(e): # 간선의 수만큼 반복 a, b, c = map(int, input().s.. 2023. 1. 15.
[Dijkstra] 1916 최소비용 구하기 https://www.acmicpc.net/problem/1916 1916번: 최소비용 구하기 첫째 줄에 도시의 개수 N(1 ≤ N ≤ 1,000)이 주어지고 둘째 줄에는 버스의 개수 M(1 ≤ M ≤ 100,000)이 주어진다. 그리고 셋째 줄부터 M+2줄까지 다음과 같은 버스의 정보가 주어진다. 먼저 처음에는 그 www.acmicpc.net # 2023.01.12 import sys input=sys.stdin.readline import heapq n=int(input()) m=int(input()) graph=[[] for _ in range(n+1)] for i in range(m): a, b, c = map(int, input().split()) graph[a].append((b, c)) st.. 2023. 1. 12.
[BFS] 7569 토마토 https://www.acmicpc.net/problem/7569 7569번: 토마토 첫 줄에는 상자의 크기를 나타내는 두 정수 M,N과 쌓아올려지는 상자의 수를 나타내는 H가 주어진다. M은 상자의 가로 칸의 수, N은 상자의 세로 칸의 수를 나타낸다. 단, 2 ≤ M ≤ 100, 2 ≤ N ≤ 100, www.acmicpc.net # 2023.01.09 import sys input = sys.stdin.readline from collections import deque m, n, h = map(int, input().split()) tomato=[[list(map(int, input().split())) for _ in range(n)] for _ in range(h)] queue=deque() .. 2023. 1. 9.
[Deque] 5430 AC https://www.acmicpc.net/problem/5430 5430번: AC 각 테스트 케이스에 대해서, 입력으로 주어진 정수 배열에 함수를 수행한 결과를 출력한다. 만약, 에러가 발생한 경우에는 error를 출력한다. www.acmicpc.net # 2023.01.08 import sys input = sys.stdin.readline from collections import deque t = int(input()) for i in range(t): p=list(input().strip()) n=int(input()) if n==0: number=input() number=[] else: number=deque(input().strip()[1:-1].split(",")) R=0 answer=1.. 2023. 1. 8.