본문 바로가기

Problem Solving/BOJ60

[Dict] 2143 두 배열의 합 https://www.acmicpc.net/problem/2143 2143번: 두 배열의 합 첫째 줄에 T(-1,000,000,000 ≤ T ≤ 1,000,000,000)가 주어진다. 다음 줄에는 n(1 ≤ n ≤ 1,000)이 주어지고, 그 다음 줄에 n개의 정수로 A[1], …, A[n]이 주어진다. 다음 줄에는 m(1 ≤ m ≤ 1,000)이 주어지고, 그 www.acmicpc.net # 2023.01.15 import sys input = sys.stdin.readline from collections import defaultdict t = int(input()) n = int(input()) A = list(map(int, input().split())) m = int(input()) B = .. 2023. 1. 15.
[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.