From 51ffa8080e7a77b6c33844e511c2db5cc1bdc8e7 Mon Sep 17 00:00:00 2001 From: YoonYn9915 Date: Sat, 21 Jun 2025 23:25:22 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[BOJ]=20=EC=9D=B4=EB=AA=A8=ED=8B=B0?= =?UTF-8?q?=EC=BD=98/=20=EA=B3=A8=EB=93=9C=204=20/=2070=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/14226 --- ...64\353\252\250\355\213\260\354\275\230.py" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "YoonYn9915/Graph/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/YoonYn9915/Graph/2025-06-16-[\353\260\261\354\244\200]-#14226-\354\235\264\353\252\250\355\213\260\354\275\230.py" "b/YoonYn9915/Graph/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..0a0b1bc --- /dev/null +++ "b/YoonYn9915/Graph/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,34 @@ +from collections import deque +import sys + +S = int(sys.stdin.readline().strip()) + +# visited[screen][clipboard] +visited = [[-1] * (S + 1) for _ in range(S + 1)] + +queue = deque() +queue.append((1, 0)) # 화면: 1, 클립보드: 0 +visited[1][0] = 0 + +while queue: + screen, clipboard = queue.popleft() + + # 목표 이모티콘 수에 도달하면 종료 + if screen == S: + print(visited[screen][clipboard]) + break + + # 1. 복사 (화면 -> 클립보드) + if visited[screen][screen] == -1: + visited[screen][screen] = visited[screen][clipboard] + 1 + queue.append((screen, screen)) + + # 2. 붙여넣기 (클립보드 -> 화면) + if clipboard != 0 and screen + clipboard <= S and visited[screen + clipboard][clipboard] == -1: + visited[screen + clipboard][clipboard] = visited[screen][clipboard] + 1 + queue.append((screen + clipboard, clipboard)) + + # 3. 삭제 (화면 -1) + if screen - 1 >= 0 and visited[screen - 1][clipboard] == -1: + visited[screen - 1][clipboard] = visited[screen][clipboard] + 1 + queue.append((screen - 1, clipboard)) From 693043f624cff71f18d118d2cea9c9e104175cc3 Mon Sep 17 00:00:00 2001 From: YoonYn9915 Date: Sat, 21 Jun 2025 23:34:57 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[BOJ]=20=EC=88=A8=EB=B0=94=EA=BC=AD?= =?UTF-8?q?=EC=A7=88=203=20/=20=EA=B3=A8=EB=93=9C=205=20/=2040=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/13549 --- ...\353\260\224\352\274\255\354\247\210 3.py" | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "YoonYn9915/Graph/2025-06-21-[\353\260\261\354\244\200]-#13549-\354\210\250\353\260\224\352\274\255\354\247\210 3.py" diff --git "a/YoonYn9915/Graph/2025-06-21-[\353\260\261\354\244\200]-#13549-\354\210\250\353\260\224\352\274\255\354\247\210 3.py" "b/YoonYn9915/Graph/2025-06-21-[\353\260\261\354\244\200]-#13549-\354\210\250\353\260\224\352\274\255\354\247\210 3.py" new file mode 100644 index 0000000..faa5197 --- /dev/null +++ "b/YoonYn9915/Graph/2025-06-21-[\353\260\261\354\244\200]-#13549-\354\210\250\353\260\224\352\274\255\354\247\210 3.py" @@ -0,0 +1,50 @@ +import sys +from collections import deque + +inp = sys.stdin.readline + +N, K = map(int, inp().strip().split()) +# 해당 위치로 도달한 최소 시간 저장 +visited = [-1] * (100_000 + 1) +visited[N] = 0 + +# (위치, 시간) 형식 +queue = deque() +queue.append((N, 0)) + +dx = [2, -1, 1] + +min_time = -1 + +while queue: + subin_loc, time = queue.popleft() + + # 수빈이가 동생에게 도달한 시간까지만 bfs탐색하고 그 후에 종료 + if min_time != -1 and min_time + 2 == time: + break + + # 수빈이가 동생에게 도달한 시간체크 + if min_time == -1 and subin_loc == K: + min_time = visited[subin_loc] + + # 수빈의 위치에서 3가지 이동 + for i in range(3): + if i == 0: + new_loc = subin_loc * dx[i] + else: + new_loc = subin_loc + dx[i] + + # 새 위치가 범위 안 + if 0 <= new_loc <= 100_000: + # 새로 방문한 위치가 이전에 와보지 못했다면, + if visited[new_loc] == -1: + # 방문 시간 설정해주고 경로 초기화 + if i == 0: + visited[new_loc] = visited[subin_loc] + queue.append((new_loc, time)) + else: + visited[new_loc] = visited[subin_loc] + 1 + queue.append((new_loc, time + 1)) + + +print(visited[K]) From 3263a8e984bb317b5a56b1532028236faab0b872 Mon Sep 17 00:00:00 2001 From: YoonYn9915 Date: Sat, 21 Jun 2025 23:38:20 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[BOJ]=20=EC=8A=A4=ED=83=9D=20/=20=EC=8B=A4?= =?UTF-8?q?=EB=B2=84=204=20/=2040=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/10828 --- ...4\200]-#10828-\354\212\244\355\203\235.py" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "YoonYn9915/implementation/2025-06-21-[\353\260\261\354\244\200]-#10828-\354\212\244\355\203\235.py" diff --git "a/YoonYn9915/implementation/2025-06-21-[\353\260\261\354\244\200]-#10828-\354\212\244\355\203\235.py" "b/YoonYn9915/implementation/2025-06-21-[\353\260\261\354\244\200]-#10828-\354\212\244\355\203\235.py" new file mode 100644 index 0000000..148c1bc --- /dev/null +++ "b/YoonYn9915/implementation/2025-06-21-[\353\260\261\354\244\200]-#10828-\354\212\244\355\203\235.py" @@ -0,0 +1,30 @@ +import sys +input = sys.stdin.readline + +N = int(input()) + +stack = [] +def query(): + Q = input().split() + if Q[0] == "push": + stack.append(int(Q[1])) + elif Q[0] == "pop": + if len(stack): + print(stack.pop()) + else: + print(-1) + elif Q[0] == "size": + print(len(stack)) + elif Q[0] == "empty": + if len(stack): + print(0) + else: + print(1) + elif Q[0] == "top": + if len(stack): + print(stack[-1]) + else: + print(-1) + +for _ in range(N): + query() \ No newline at end of file