-
Notifications
You must be signed in to change notification settings - Fork 2
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
16-H0ngJu #191
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() | ||
|
||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ ๊ฐ๋ฅผ ๋ถ๋ฆฌํ๋ ๊ฒ๋ ๊ด์ฐฎ์๋ฐ ์ ๊ฐ ๋ดค์ ๋ ๋ ๊ฐ์ ์ฑ๊ฒฉ์ด ๋น์ทํ ๊ฒ ๊ฐ์์ ๊ตณ์ด ๋๋ ํ์ ์์ ๊ฒ ๊ฐ์์! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ ๋ ํ๋๋ก ํ์ต๋๋ฅ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ ์๊ฐํด๋ณด๋๊น ๊ทธ๋ฌ๋ค์ ๋ฑ ์ฌ๋ค๋ฆฌ ํด์ ๊ทธ๋ฅ ๊ตฌ๋ถ์ง์ด๋ฒ๋ ธ๋ค์ ..
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ด์งํผ ๋ฐ์๋ start end๋ ๊ฐ๋๋ผ๊ตฌ์!! ๋ฑ์ ์๋๋ก ๋ด๋ ค๊ฐ์ง๋ง input์ ๋์ผํ๊ฒ |
||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ๋๋ก ํฉ์น ์ ์๊ฒ ๋ค์ฉ There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input ๋ฐ๊พธ์ค๋ ์ด๋ ๊ฒ ์ฐ์๋๊ตฐ์!!
์ ๋
์ผ๋ก ๋ฐ๊ฟ์ ์ ๊ธฐํ๋ค์!!