-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from AlgoLeadMe/10-H0ngJu
10-H0ngJu
- Loading branch information
Showing
2 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sys | ||
from collections import deque | ||
|
||
def input(): return sys.stdin.readline() | ||
|
||
N, K = map(int, input().split()) | ||
|
||
visited = [0] * 100001 | ||
time = 0 | ||
parent = [-1] * 100001 | ||
|
||
q = deque([N]) | ||
visited[N] = 1 | ||
|
||
while q: | ||
size = len(q) | ||
for _ in range(size): | ||
location = q.popleft() | ||
if location == K: | ||
print(time) | ||
answer = [] | ||
while location != -1: | ||
answer.append(location) | ||
location = parent[location] | ||
answer.reverse() | ||
print(" ".join(map(str, answer))) | ||
break | ||
for next_location in (location + 1, location - 1, location * 2): | ||
if 0 <= next_location <= 100000 and not visited[next_location]: | ||
q.append(next_location) | ||
visited[next_location] = 1 | ||
parent[next_location] = location | ||
time += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
## โ๏ธ ๊ธฐ๋ก | ||
|
||
| ์ฐจ์ | ๋ ์ง | ๋ฌธ์ ์ ํ | ๋งํฌ | ํ์ด | | ||
| :---: | :--------: | :------: | :-----------------------------------------------------------------------------------: | :-------------------------------------------------: | | ||
| 1์ฐจ์ | 2024.03.05 | ํ | [ํ๋ก์ธ์ค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 | | ||
| 2์ฐจ์ | 2024.03.07 | ํ | [๋ค๋ฆฌ๋ฅผ ์ง๋๋ ํธ๋ญ](https://school.programmers.co.kr/learn/courses/30/lessons/42583) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/153 | | ||
| 3์ฐจ์ | 2024.03.10 | ํ | [N๋ฒ์งธ ํฐ ์](https://www.acmicpc.net/problem/2075) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/156 | | ||
| 4์ฐจ์ | 2024.03.13 | ํ | [๋ฌธ์ ์ง](https://www.acmicpc.net/problem/1766) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/158 | | ||
| 5์ฐจ์ | 2024.03.16 | ๊ตฌํ | [์์ธํธ์ค ๋ฌธ์ ](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 | | ||
| 6์ฐจ์ | 2024.03.19 | ์คํ | [์คํฐ์](https://www.acmicpc.net/problem/17298) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/164 | | ||
| 7์ฐจ์ | 2024.03.22 | DP | [1,2,3 ๋ํ๊ธฐ](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/166 | | ||
| ์ฐจ์ | ๋ ์ง | ๋ฌธ์ ์ ํ | ๋งํฌ | ํ์ด | | ||
| :----: | :--------: | :------: | :-----------------------------------------------------------------------------------: | :-------------------------------------------------: | | ||
| 1์ฐจ์ | 2024.03.05 | ํ | [ํ๋ก์ธ์ค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 | | ||
| 2์ฐจ์ | 2024.03.07 | ํ | [๋ค๋ฆฌ๋ฅผ ์ง๋๋ ํธ๋ญ](https://school.programmers.co.kr/learn/courses/30/lessons/42583) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/153 | | ||
| 3์ฐจ์ | 2024.03.10 | ํ | [N๋ฒ์งธ ํฐ ์](https://www.acmicpc.net/problem/2075) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/156 | | ||
| 4์ฐจ์ | 2024.03.13 | ํ | [๋ฌธ์ ์ง](https://www.acmicpc.net/problem/1766) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/158 | | ||
| 5์ฐจ์ | 2024.03.16 | ๊ตฌํ | [์์ธํธ์ค ๋ฌธ์ ](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 | | ||
| 6์ฐจ์ | 2024.03.19 | ์คํ | [์คํฐ์](https://www.acmicpc.net/problem/17298) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/164 | | ||
| 7์ฐจ์ | 2024.03.22 | DP | [1,2,3 ๋ํ๊ธฐ](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/166 | | ||
| 8์ฐจ์ | 2024.03.16 | DP | [์ฌ์ด ๊ณ๋จ ์](https://www.acmicpc.net/problem/10844) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/170 | | ||
| 9์ฐจ์ | 2024.03.22 | DP | [RGB๊ฑฐ๋ฆฌ 2](https://www.acmicpc.net/problem/17404) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/172 | | ||
| 10์ฐจ์ | 2024.04.03 | BFS | [์จ๋ฐ๊ผญ์ง 4](https://www.acmicpc.net/problem/13913) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/177 | | ||
|
||
--- |