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

16-H0ngJu #191

Merged
merged 1 commit into from
May 23, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import sys
from collections import deque

def input(): return sys.stdin.readline().rstrip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input ๋ฐ”๊พธ์‹ค๋•Œ ์ด๋ ‡๊ฒŒ ์“ฐ์‹œ๋Š”๊ตฐ์š”!!
์ €๋Š”

input = sys.stdin.readline

์œผ๋กœ ๋ฐ”๊ฟ”์„œ ์‹ ๊ธฐํ•˜๋„ค์š”!!


N, M = map(int, input().split())
ladder = [list(map(int, input().split())) for _ in range(N)]
snake = [list(map(int, input().split())) for _ in range(M)]
Comment on lines +7 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‘ ๊ฐœ๋ฅผ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ๋„ ๊ดœ์ฐฎ์€๋ฐ ์ œ๊ฐ€ ๋ดค์„ ๋• ๋‘ ๊ฐœ์˜ ์„ฑ๊ฒฉ์ด ๋น„์Šทํ•œ ๊ฒƒ ๊ฐ™์•„์„œ ๊ตณ์ด ๋‚˜๋ˆŒ ํ•„์š” ์—†์„ ๊ฒƒ ๊ฐ™์•„์š”!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ €๋„ ํ•˜๋‚˜๋กœ ํ–ˆ์Šต๋‹ˆ๋‘ฅ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•— ์ƒ๊ฐํ•ด๋ณด๋‹ˆ๊นŒ ๊ทธ๋Ÿฌ๋„ค์š”
์–ด์ฐจํ”ผ a,b๋ฅผ ๋ฐ›์•˜์„ ๋•Œ a>b์ด๋ฉด ๋ฑ€์ด๊ณ  a<b๋ฉด ์‚ฌ๋‹ค๋ฆฌ๋‹ˆ๊นŒ ..

๋ฑ€ ์‚ฌ๋‹ค๋ฆฌ ํ•ด์„œ ๊ทธ๋ƒฅ ๊ตฌ๋ถ„์ง€์–ด๋ฒ„๋ ธ๋„ค์š” ..
์ƒ๊ฐ์น˜๋„ ๋ชปํ–ˆ๋˜ ๋ถ€๋ถ„์ธ๋ฐ ์ฝ”๋ฉ˜ํŠธ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ท ~~

Comment on lines +7 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์–ด์งœํ”ผ ๋ฐ›์„๋•Œ start end๋Š” ๊ฐ™๋”๋ผ๊ตฌ์š”!!
์‚ฌ๋‹ค๋ฆฌ ๋จผ์ € ๋ฐ›์ง€๋งŒ ์‚ฌ๋‹ค๋ฆฌ๋Š” ์œ„๋กœ ์˜ฌ๋ผ๊ฐ€๋Š”๋ฐ
start -> end๋กœ start < end๊ฐ€ ๋˜๊ณ 

๋ฑ€์€ ์•„๋ž˜๋กœ ๋‚ด๋ ค๊ฐ€์ง€๋งŒ input์€ ๋™์ผํ•˜๊ฒŒ
start -> end๋กœ start > end๊ฐ€ ๋˜๋Š” ๋‹ค๋ฅธ์ ๋งŒ ์žˆ์„๋ฟ ๊ฐ™๋”๋ผ๊ตฌ์š”!

game = [i for i in range(1,101)]
visited = [0 for _ in range(100)]
q = deque()

q.append((1,0))
visited[0] = 1

while q:
cur, dice = q.popleft()
if cur == 100:
print(dice)
break
for i in range(1, 7):
check = 0

if cur + i > 100: continue

# ์‚ฌ๋‹ค๋ฆฌ ๊ฐˆ ์ˆ˜ ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌ
for l, n in ladder:
if cur + i == l:
if visited[n-1] == 0:
q.append((n, dice+1))
visited[n-1] = 1
check = 1
break

if check: continue
# ๋ฑ€ ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌ
for s, n in snake:
if cur + i == s:
if visited[n-1] == 0:
q.append((n, dice+1))
visited[n-1] = 1
check = 1
break

Comment on lines +26 to +44
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ•˜๋‚˜๋กœ ํ•ฉ์น  ์ˆ˜ ์žˆ๊ฒ ๋„ค์šฉ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ทธ๋Ÿฌ๋„ค์š” ์ด์ œ check๋„ ํ•„์š” ์—†๋„ค์š” .. ๐Ÿ”จ๐Ÿ”จ

if check: continue
# ๊ทธ ์™ธ
if visited[cur + i-1] == 0:
q.append((cur + i, dice + 1))
visited[cur + i-1] = 1
1 change: 1 addition & 0 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
| 13์ฐจ์‹œ | 2024.05.06 | ์™„์ „ํƒ์ƒ‰ | [๋ฆฌ๋ชจ์ปจ](https://www.acmicpc.net/problem/1107) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/181 |
| 14์ฐจ์‹œ | 2024.05.09 | DFS | [์น˜ํ‚จ๋ฐฐ๋‹ฌ](https://www.acmicpc.net/problem/15686) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/183 |
| 15์ฐจ์‹œ | 2024.05.14 | ๊ทธ๋ฆฌ๋”” | [A์™€ B](https://www.acmicpc.net/problem/12904) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/188 |
| 16์ฐจ์‹œ | 2024.05.14 | BFS | [๋ฑ€๊ณผ ์‚ฌ๋‹ค๋ฆฌ ๊ฒŒ์ž„](https://www.acmicpc.net/problem/16928) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/191 |

---
Loading