[백준] 14888 연산자 끼워넣기 Python3 DFS
이거 보자마자 생각난 문제https://school.programmers.co.kr/learn/courses/30/lessons/43165 n = int(input())arr = list(map(int,input().split()))plus, minus, cross, div = list(map(int,input().split()))max_ = - int(1e9)min_ = int(1e9)def dfs(plus, minus, cross, div, sum, idx): global max_, min_ if idx == n: max_ = max(max_, sum) min_ = min(min_, sum) return if plus: dfs(plus..
[백준] 2583 영역구하기 bfs 실1
이제 bfs 문제 보면 대충 그림+빙산 조합으로 풀면 되겠네...이런 생각 함 from collections import dequem, n, k = map(int, input().split())arr = [[0 for _ in range(n)] for _ in range(m)]for _ in range(k): x1, y1, x2, y2 = map(int, input().split()) for y in range(y1, y2): for x in range(x1, x2): arr[m - y - 1][x] = 1 dx = [0, 0, 1, -1]dy = [1, -1, 0, 0]def bfs(y, x, visited): q = deque() q.append..
[백준] 2468 안전영역 BFS
from collections import dequen = int(input())arr = [list(map(int, input().split())) for _ in range(n)]def bfs(i,j,k,visited): q=deque() q.append([i,j]) dx=[0,0,1,-1] dy=[1,-1,0,0] while q: y,x = q.popleft() visited[y][x] = True for i in range(4): y_=y+dy[i] x_=x+dx[i] if 0y_n and 0x_n and not visited[y_][x_] and arr[y_][x_]>k: ..