From a555d7df4999853301c033182c318af0de0334bf Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Wed, 18 Jun 2025 09:22:34 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[BOJ]=20#14226.=20=EC=9D=B4=EB=AA=A8?= =?UTF-8?q?=ED=8B=B0=EC=BD=98=20/=20=EA=B3=A8=EB=93=9C4=20/=2040=EB=B6=84?= =?UTF-8?q?=20/=20=ED=9E=8C=ED=8A=B8,=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...64\353\252\250\355\213\260\354\275\230.py" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "minjeong/DFSBFS/2025-06-16-[\353\260\261\354\244\200]-#14226-\354\235\264\353\252\250\355\213\260\354\275\230.py" diff --git "a/minjeong/DFSBFS/2025-06-16-[\353\260\261\354\244\200]-#14226-\354\235\264\353\252\250\355\213\260\354\275\230.py" "b/minjeong/DFSBFS/2025-06-16-[\353\260\261\354\244\200]-#14226-\354\235\264\353\252\250\355\213\260\354\275\230.py" new file mode 100644 index 0000000..006b4c5 --- /dev/null +++ "b/minjeong/DFSBFS/2025-06-16-[\353\260\261\354\244\200]-#14226-\354\235\264\353\252\250\355\213\260\354\275\230.py" @@ -0,0 +1,38 @@ +import sys +from collections import deque +input = sys.stdin.readline + +# 1. 입력 및 초기화 +S = int(input()) +MAX = 1001 + +# visited[screen][clipboard] = 해당 상태까지 걸린 시간 +visited = [[-1] * MAX for _ in range(MAX)] +visited[1][0] = 0 + +queue = deque([(1, 0)]) # 화면 임티 개수, 클립보드 임티 개수 + +# 2. BFS 탐색 +while queue: + screen, clip = queue.popleft() + + # 3. 목표 달성 시 종료 + if screen == S: + print(visited[screen][clip]) + break + + for i in range(3): + if i == 0: # 복사 (화면 → 클립보드) + new_screen, new_clipboard = screen, screen + elif i == 1: # 붙여넣기 (클립보드 → 화면) + new_screen, new_clipboard = screen + clip, clip + else: # 삭제 (화면 - 1) + new_screen, new_clipboard = screen - 1, clip + + if new_screen >= MAX or new_screen < 0 \ + or new_clipboard >= MAX or new_clipboard < 0 \ + or visited[new_screen][new_clipboard] != -1: + continue + + visited[new_screen][new_clipboard] = visited[screen][clip] + 1 + queue.append((new_screen, new_clipboard)) From c6a31135fcd8d620ab820d724a98f4cfc8145942 Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Sun, 22 Jun 2025 01:14:55 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[PGS]=20=ED=82=A4=ED=8C=A8=EB=93=9C?= =?UTF-8?q?=EB=88=84=EB=A5=B4=EA=B8=B0=20/=20Level1=20/=2030=EB=B6=84=20/?= =?UTF-8?q?=20=ED=9E=8C=ED=8A=B8,=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\353\210\204\353\245\264\352\270\260.py" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "minjeong/Greedy/2025-06-22-[\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244]-\355\202\244\355\214\250\353\223\234\353\210\204\353\245\264\352\270\260.py" diff --git "a/minjeong/Greedy/2025-06-22-[\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244]-\355\202\244\355\214\250\353\223\234\353\210\204\353\245\264\352\270\260.py" "b/minjeong/Greedy/2025-06-22-[\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244]-\355\202\244\355\214\250\353\223\234\353\210\204\353\245\264\352\270\260.py" new file mode 100644 index 0000000..ab54b4b --- /dev/null +++ "b/minjeong/Greedy/2025-06-22-[\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244]-\355\202\244\355\214\250\353\223\234\353\210\204\353\245\264\352\270\260.py" @@ -0,0 +1,45 @@ +def solution(numbers, hand): + answer = '' + pad = {'1': (0, 0), '2': (0, 1), '3': (0, 2), + '4': (1, 0), '5': (1, 1), '6': (1, 2), + '7': (2, 0), '8': (2, 1), '9': (2, 2), + '*': (3, 0), '0': (3, 1), '#': (3, 2) + } + + left = pad['*'] + right = pad['#'] + + for num in numbers: + # 왼손이 눌러야 하는 번호 + if num in (1, 4, 7): + answer += 'L' + left = pad[str(num)] + # 오른손이 눌러야 하는 번호 + elif num in (3, 6, 9): + answer += 'R' + right = pad[str(num)] + # 가운데 번호일 경우 (2, 5, 8, 0) + else: + + # 해당 번호와 왼손 거리 + left_dist = abs(left[0] - pad[str(num)][0]) + abs(left[1] - pad[str(num)][1]) + # 해당 번호와 오른손 거리 + right_dist = abs(right[0] - pad[str(num)][0]) + abs(right[1] - pad[str(num)][1]) + + # 더 가까운 거리 + if left_dist < right_dist: + answer += 'L' + left = pad[str(num)] + elif left_dist > right_dist: + answer += 'R' + right = pad[str(num)] + # 왼손과 오른손 거리가 같을 경우 + else: + if hand == 'right': + answer += 'R' + right = pad[str(num)] + else: + answer += 'L' + left = pad[str(num)] + + return answer \ No newline at end of file From ee610f20a96b051337369c7899ec720c5d7fcdb6 Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Sun, 22 Jun 2025 09:14:40 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[BOJ]=20#13549.=20=EC=88=A8=EB=B0=94?= =?UTF-8?q?=EA=BC=AD=EC=A7=88=203=20/=20=EA=B3=A8=EB=93=9C5=20/=2020?= =?UTF-8?q?=EB=B6=84=20/=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\353\260\224\352\274\255\354\247\2103.py" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "minjeong/DFSBFS/2025-06-21-[\353\260\261\354\244\200]-#13549-\354\210\250\353\260\224\352\274\255\354\247\2103.py" diff --git "a/minjeong/DFSBFS/2025-06-21-[\353\260\261\354\244\200]-#13549-\354\210\250\353\260\224\352\274\255\354\247\2103.py" "b/minjeong/DFSBFS/2025-06-21-[\353\260\261\354\244\200]-#13549-\354\210\250\353\260\224\352\274\255\354\247\2103.py" new file mode 100644 index 0000000..0fc7d51 --- /dev/null +++ "b/minjeong/DFSBFS/2025-06-21-[\353\260\261\354\244\200]-#13549-\354\210\250\353\260\224\352\274\255\354\247\2103.py" @@ -0,0 +1,28 @@ +import sys +from collections import deque +input = sys.stdin.readline + +MAX = 100000 +N, K = map(int, input().split()) +visited = [-1] * (MAX + 1) + +queue = deque() +queue.append(N) +visited[N] = 0 + +while queue: + current = queue.popleft() + + # 순간이동 (0초) -> 큐 앞쪽에 넣기 + nx = current * 2 + if 0 <= nx <= MAX and visited[nx] == -1: + visited[nx] = visited[current] + queue.appendleft(nx) # 핵심! + + # 걷는 경우 (+1, -1) -> 큐 뒤쪽에 넣기 + for nx in (current - 1, current + 1): + if 0 <= nx <= MAX and visited[nx] == -1: + visited[nx] = visited[current] + 1 + queue.append(nx) + +print(visited[K])