[백준 9207번] 페그 솔리테어
9207번: 페그 솔리테어 각 테스트 케이스에 대해서, 핀을 움직여서 남길 수 있는 핀의 최소 개수와 그 개수를 만들기 위해 필요한 최소 이동 횟수를 출력한다. www.acmicpc.net from collections import deque n = int(input()) dx = [-1,1,0,0] dy = [0,0,-1,1] dx_2 = [-2,2,0,0] dy_2 = [0,0,-2,2] result = [] def move(movetime): global min_count, min_movement pin_list = [] for i in range(5): for j in range(9): if area[i][j] == 'o': pin_list.append((i,j)) if len(pin_list) ..
2023. 8. 23.
[백준 15686번] 치킨 배달
15686번: 치킨 배달 크기가 N×N인 도시가 있다. 도시는 1×1크기의 칸으로 나누어져 있다. 도시의 각 칸은 빈 칸, 치킨집, 집 중 하나이다. 도시의 칸은 (r, c)와 같은 형태로 나타내고, r행 c열 또는 위에서부터 r번째 칸 www.acmicpc.net import itertools def calculate_distance(r1,c1,r2,c2): return abs(r1-r2) + abs(c1-c2) n, m = map(int,input().split()) input_city = [list(map(int,input().split())) for _ in range(n)] chicken_house_list = set() house_list = set() min_value = float("inf..
2023. 8. 20.
[백준 21610번] 마법사 상어와 비바라기
n,m = map(int,input().split()) area = [list(map(int,input().split())) for _ in range(n)] move_list = [] # 이동 정보 목록 for i in range(m): move_list.append(tuple(map(int,input().split()))) cloud_list= {(n-1,0), (n-1,1), (n-2,0), (n-2,1)} # 초기 구름 위치 dx = [0,-1, -1, -1, 0, 1, 1, 1] # 방향 x좌표 dy = [-1, -1, 0, 1, 1, 1, 0, -1] # 방향 y좌표 dx_2 = [-1,-1,1,1] # 대각선 이동을 위한 x좌표 dy_2 = [-1,1,-1,1] # 대각선 이동을 위한 y좌표..
2023. 8. 15.