From 239481f430a1b2548bbd2596f500ef7e8b15ede9 Mon Sep 17 00:00:00 2001 From: seongwon030 <105052068+seongwon030@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:39:46 +0900 Subject: [PATCH 1/2] =?UTF-8?q?2024-03-25=2013549=EC=88=A8=EB=B0=94?= =?UTF-8?q?=EA=BC=AD=EC=A7=883?= 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 "seongwon030/bfs/\354\210\250\353\260\224\352\274\255\354\247\2103.py" diff --git "a/seongwon030/bfs/\354\210\250\353\260\224\352\274\255\354\247\2103.py" "b/seongwon030/bfs/\354\210\250\353\260\224\352\274\255\354\247\2103.py" new file mode 100644 index 0000000..8676b7f --- /dev/null +++ "b/seongwon030/bfs/\354\210\250\353\260\224\352\274\255\354\247\2103.py" @@ -0,0 +1,28 @@ +from collections import deque +import sys + +input = sys.stdin.readline + +result = 0 +MAX = 10**5 # 움직일 수 있는 최대좌표 +dist = [-1] * (MAX + 1) # 해당 위치에 도착했을 때 시간 +n, k = map(int,input().split()) + +q = deque() +q.append(n) +dist[n] = 0 # 시작위치를 체크하기 위해 0으로 설정 +while q: + x = q.popleft() + if x==k: # x변수인 수빈의 위치가 동생이 있는 k와 같을 때 멈춤 + result = dist[x] + break + # nx = 4,6,10 (현재 위치 5일 때 이동할 수 있는 방향) + for nx in (x*2, x-1, x+1): + # 범위내에 있고 아직 방문안했다면 + if 0<=nx<=MAX and dist[nx] == -1: + if nx == x*2: # 곱하기2를 한 좌표부터 체크 + dist[nx] = dist[x] + else: + dist[nx] = dist[x] + 1 + q.append(nx) +print(result) \ No newline at end of file From 724573616f6a0bd4a8f33d04e8775e54df73410a Mon Sep 17 00:00:00 2001 From: seongwon030 <105052068+seongwon030@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:31:45 +0900 Subject: [PATCH 2/2] 2024-03-25 update readme --- seongwon030/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/seongwon030/README.md b/seongwon030/README.md index 0a76bfa..cef8891 100644 --- a/seongwon030/README.md +++ b/seongwon030/README.md @@ -1,9 +1,10 @@ ## ✏️ 기록 -| 차시 | 날짜 | 문제유형 | 링크 | 풀이 | -| :---: | :--------: | :------: | :-----------------------------------------------: | :------------------------------------------------------: | -| 1차시 | 2024.03.11 | 스택 | [쇠막대기](https://www.acmicpc.net/problem/10799) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/2) | -| 2차시 | 2024.03.16 | BFS | [토마토](https://www.acmicpc.net/problem/7576) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/7) | -| 3차시 | 2024.03.19 | BFS | [토마토](https://www.acmicpc.net/problem/7569) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/9) | +| 차시 | 날짜 | 문제유형 | 링크 | 풀이 | +| :---: | :--------: | :------: | :------------------------------------------------: | :------------------------------------------------------: | +| 1차시 | 2024.03.11 | 스택 | [쇠막대기](https://www.acmicpc.net/problem/10799) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/2) | +| 2차시 | 2024.03.16 | BFS | [토마토](https://www.acmicpc.net/problem/7576) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/7) | +| 3차시 | 2024.03.19 | BFS | [토마토](https://www.acmicpc.net/problem/7569) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/9) | +| 4차시 | 2024.03.25 | BFS | [숨바꼭질3](https://www.acmicpc.net/problem/13549) | [#17](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/9) | ---