[이코테/bfs/삼성 기출] 인구 이동(정답, 풀이, 풀리지 않는 의문..)
문제 https://www.acmicpc.net/problem/16234 https://www.acmicpc.net/problem/16234 정답 from collections import deque n,l,r = map(int,input().split()) graph =[] for _ in range(n): graph.append(list(map(int,input().split()))) dx = [1,0,1,0] dy = [0,-1,0,1] def process(x,y,index): # 한 연합의 인구이동 로직 united = [] # 한 연합에 포함되는 나라가 담길 배열. 인구이동 시 필요 united.append((x,y)) q = deque() # dfs수행. 국경선을 여는 조건에 따라 연합을 확..
[이코테/dfs/삼성기출] 연산자 끼워넣기(정답,해설)
문제 14888번: 연산자 끼워넣기 첫째 줄에 수의 개수 N(2 ≤ N ≤ 11)가 주어진다. 둘째 줄에는 A1, A2, ..., AN이 주어진다. (1 ≤ Ai ≤ 100) 셋째 줄에는 합이 N-1인 4개의 정수가 주어지는데, 차례대로 덧셈(+)의 개수, 뺄셈(-)의 개수, 곱 www.acmicpc.net 정답(순열) from itertools import permutations n = int(input()) nums = list(map(int,input().split())) data = list(map(int,input().split())) exam = ["p","m","c","d"] opers = [] for d in range(len(data)): for _ in range(data[d]): op..