-
Notifications
You must be signed in to change notification settings - Fork 0
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
5-seongwon030 #23
5-seongwon030 #23
Conversation
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.
λ± μ²μ λ΄€μλ DPλ¬Έμ λ€? λΌκ³ μκ°νλλ° BFSλ‘ μ κ·Όλμ΄ μμ΄μ 쑰건μ νμΈν΄λ³΄λ 1000 μ΄νλ©΄ κ°λ₯ν κ²? κ°κΈ°λ νκ³ μκ°μ΄ λ€λκ΅°μ...
μ μ΄μ ν μ€μ΄λΌ μ΄λ»κ² νλ μκ΄μλ€κ³ λ€κΈ΄ νμ΅λλ€. μ¬κΈ°μλ μ νλ‘ κ° μ μλ νμΉΈ νμΉΈ λ°©λ¬Ένλμ§ μ²΄ν¬νλ©° κ°λ€μ.
μ€κ°μ μμ κ°μ΄ λ€μ΄μ€λ©΄ μ΄λ‘νμ§ μκ°νλλ° μ μ΄μ μ μ
μ μΆ νΉμ±μ΄λΌ λ¨Όμ λΉ μ Έλκ°λ κ²μ νμ¬λ³΄λ€ μμ κ°μ΄κΈ°μ μκ΄μλ€κ³ λ°λ‘ κΉ¨λ¬μμ΅λλ€!
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.
κΈ°μ μ΄λ κ² νΌκ±° DPλ‘ νμμ λλ BFSλ‘ νμμ λ νμ μ°¨μ΄λ μ 리ν΄μ£Όμ
¨μΌλ©΄ μ’κ² μ΄μ!
κ·Έλ¦¬κ³ μ§κΈμ queueμμ popν curμ΄ μ λ΅μΈμ§ νμΈνλ λ‘μ§μ΄λΌλ©΄ νΉμ queueμ λ£κΈ° μ μ νλ¨ν΄μ νμμ μ’
λ£νλ λ°©λ²μΌλ‘λ ν μ μμκΉμ?
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.
μ λ κ° μΉΈλ§λ€ μ΅μ μ ννμλ₯Ό μ μ₯νλ λ°°μ΄μ μ΄μ©νμ¬ dpλ°©μ
μΌλ‘ ν μ€ μμλλ° bfs
λ‘λ νμ μκ΅°μ.. νΉμ λμ€μ dpλ°©μμΌλ‘λ νμ΄λ³΄μ λ€λ©΄ λ λ°©μμ μκ°λ³΅μ‘λ μ°¨μ΄
λ₯Ό μ μ μμκΉμ..?
for i in range(1, k[cur] + 1): # kμμ μλ μ«μ μ΄νλ§νΌ μ€λ₯Έμͺ½μΌλ‘ μ ν κ°λ₯
next = cur + i
if next not in visited:
visited.append(next)
if next == len(k) - 1: # λ€μ μΈλ±μ€κ° λ§μ§λ§ μΉΈμ΄λ©΄ jumpμΆλ ₯ ν μ’
λ£
print(jump + 1)
exit()
queue.append((next, jump + 1)) νμ λ£κΈ° μ μ λ°λ‘ νμΈνλκΉ μκ°λ³΅μ‘λκ° κ°μ λλ€μ! dpλ‘ λ€μ νμ΄λ³΄κ³ 리뷰 λ¨κΈΈκ²μ© |
π λ¬Έμ λ§ν¬
μ νμ ν
βοΈ μμλ μκ°
2μκ°
β¨ μλ μ½λ
νμ¬ μΈλ±μ€μ μ ν νμ
λ₯Ό νμ λ£λλ€.λ°©λ¬Έ μ¬λΆ 체ν¬
λ₯Ό μν 리μ€νΈλ₯Ό λ§λ λ€.νμ¬ μΈλ±μ€μ μ νμΈλ±μ€ νν
μ νμμ κΊΌλΈλ€.νμ¬ μΈλ±μ€κ° λ§μ§λ§ μΉΈμ ν΄λΉ
νλ©΄ jump μΆλ ₯ ν μ’ λ£νλ€.k 리μ€νΈ μμ μ«μ μ΄ν
λ§νΌ λ°λ³΅νλ€π μλ‘κ² μκ²λ λ΄μ©
bfs λ‘ νμλλ° dpλ¬Έμ μλ€.. dp λ‘ λ€μ νμ΄λ³΄λλ‘ νκ² μ΅λλ€