Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

33-alstjr7437 #236

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions alstjr7437/BFS/DSLR.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from collections import deque
import sys

input = sys.stdin.readline

T = int(input())

def command(register, cmd):
if cmd == 0:
return ((register * 2) % 10000, "D")
elif cmd == 1:
return (9999 if register == 0 else register - 1, "S")
elif cmd == 2:
return (register % 1000 * 10 + register // 1000, "L")
elif cmd == 3:
return (register // 10 + (register % 10) * 1000, "R")

for _ in range(T):
A, B = map(int, input().split())

visited = [False] * 10000
visited[A] = True

queue = deque([(A, "")])
while queue:
cur, result = queue.popleft()

if cur == B:
print(result)
break

for i in range(4):
register, cmd = command(cur, i)
if not visited[register]:
visited[register] = True
queue.append((register, result + cmd))
7 changes: 4 additions & 3 deletions alstjr7437/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
| 27์ฐจ์‹œ | 2024.05.26 | ์šฐ์„ ์ˆœ์œ„ ํ | <a href="https://www.acmicpc.net/problem/7662">์ด์ค‘ ์šฐ์„ ์ˆœ์œ„ ํ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/198 |
| 28์ฐจ์‹œ | 2024.05.30 | ๋ธŒ๋ฃจํŠธ ํฌ์Šค | <a href="https://www.acmicpc.net/problem/6064">์นด์ž‰ ๋‹ฌ๋ ฅ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/203 |
| 29์ฐจ์‹œ | 2024.06.11 | ์ด๋ถ„ ํƒ์ƒ‰ | <a href="https://www.acmicpc.net/problem/2805">๋‚˜๋ฌด ์ž๋ฅด๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/210 |
| 30์ฐจ์‹œ | 2024.06.19 | ๋ฐฉ ๋ฒˆํ˜ธ | <a href="https://www.acmicpc.net/problem/1475">๊ตฌํ˜„</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/211 |
| 31์ฐจ์‹œ | 2024.06.19 | ๊ฒŒ์ž„ ๋งต ์ตœ๋‹จ๊ฑฐ๋ฆฌ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/1844">BFS</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/218 |
| 32์ฐจ์‹œ | 2024.08.15 | ๊ณผ์ผ ํƒ•ํ›„๋ฃจ | <a href="https://www.acmicpc.net/problem/30804">ํˆฌ ํฌ์ธํ„ฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/230 |
| 30์ฐจ์‹œ | 2024.06.19 | ๊ตฌํ˜„ | <a href="https://www.acmicpc.net/problem/1475">๋ฐฉ ๋ฒˆํ˜ธ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/211 |
| 31์ฐจ์‹œ | 2024.06.19 | BFS | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/1844">๊ฒŒ์ž„ ๋งต ์ตœ๋‹จ๊ฑฐ๋ฆฌ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/218 |
| 32์ฐจ์‹œ | 2024.08.15 | ํˆฌ ํฌ์ธํ„ฐ | <a href="https://www.acmicpc.net/problem/30804">๊ณผ์ผ ํƒ•ํ›„๋ฃจ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/230 |
| 33์ฐจ์‹œ | 2024.08.21 | BFS | <a href="https://www.acmicpc.net/problem/9019">DSLR</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/236 |
Loading