[백준] 13460번 - 구슬 탈출 2 (파이썬)
# 구슬 탈출 2 from collections import deque import sys input = sys.stdin.readline # . # 0 R B => 빈칸, 장애물, 구멍, 빨간구슬, 파란구슬 N, M = map(int, input().split()) arr = [] red_x, red_y = 0, 0 blue_x, blue_y = 0, 0 for i in range(N): arr.append(list(input().strip())) for j in range(len(arr[i])): if arr[i][j] == 'R': red_x, red_y = i, j arr[i][j] = '.' elif arr[i][j] == 'B': blue_x, blue_y = i, j arr[i][j] = '..
2022. 2. 11.
[백준] 13459번 - 구슬 탈출 (파이썬)
# 구슬 탈출 from collections import deque import sys input = sys.stdin.readline # . # 0 R B => 빈칸, 장애물, 구멍, 빨간구슬, 파란구슬 N, M = map(int, input().split()) arr = [] red_x, red_y = 0, 0 blue_x, blue_y = 0, 0 for i in range(N): arr.append(list(input().strip())) for j in range(len(arr[i])): if arr[i][j] == 'R': red_x, red_y = i, j arr[i][j] = '.' elif arr[i][j] == 'B': blue_x, blue_y = i, j arr[i][j] = '.'..
2022. 2. 11.
[백준] 1525번 - 퍼즐 (파이썬)
# 퍼즐 from collections import deque N = 3 arr = [] zero_x = 0 zero_y = 0 for i in range(N): arr.append(list(map(int, input().split()))) for j in range(N): if arr[i][j] == 0: zero_x = i zero_y = j dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] visit = dict() def bfs(a, b): global arr q = deque() string = change(arr) if string == '123456780': return '0' q.append((a, b, 0, string)) visit[string] = True while..
2022. 2. 9.
[백준] 2146번 - 다리 만들기 (파이썬)
# 다리 만들기 from collections import deque import sys input = sys.stdin.readline MAX = sys.maxsize N = int(input()) arr = [] sea = [] for i in range(N): arr.append(list(map(int, input().split()))) for j in range(N): if arr[i][j] == 0: sea.append((i, j)) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] result = MAX def bfs(a, b): global result q = deque() q.append((a, b)) visited = [[0] * N for _ in range(N)] w..
2022. 1. 28.