-
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
4-seongwon030 #16
4-seongwon030 #16
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.
λ¬Έμ λ§ν¬κ° μλͺ»λκ±° κ°μ΅λλ€~
μκ°μ΄ 0μ΄μΈ μμΈλΆλΆμ μ μ‘μμ£Όμ
¨λ κ² κ°λ€μ~
λ°©λ¬Έ λ°°μ΄μ νλλ₯Ό μ‘μμ£Όμμ κ²½μ° λ μ§κ΄μ μΌ μλ μμ§λ§ νλμ λ°°μ΄μμ λ°©λ¬Ένλ νμλ₯Ό -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.
λ°©λ¬Ένμ§μμμκ²½μ°λ₯Ό 0μΌλ‘ λλ μ€μλ₯Ό μ£Όμν΄μΌκ² λ€μ μ΄λ² prλκ³ μνμ ¨μ΅λλ€ !
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.
BFS λ¬Έμ λ§ νΈμλλ ν μ¬μ© μ€λ ₯μ΄ μ μ μ’μμ§μλ€μ. λ‘μ§λ μ§κ΄μ μ΄κ³ μ£Όμλ μΉμ ν λ¬μμ£Όμ μ μ΄ν΄νκΈ° μ¬μ μ΅λλ€ :)
π λ¬Έμ λ§ν¬
μ¨λ°κΌμ§3
βοΈ μμλ μκ°
2μκ°
β¨ μλ μ½λ
μ²μ νμ΄
μ¨λ°κΌμ§2
μμ μ‘°κΈ λ³νν΄μ μ’νκ°x*2
μΈ κ²½μ°λΆν° 쑰건μ λ¬κ³ν΄λΉ μ’νλ 0μ΄μ΄λ―λ‘ μ’νμ΄λμ μλλ‘ μ€μ νλ€.
κ³±νκΈ° 2
μ μ°μ μμλ₯Ό λ μ΄μ λλλ¨Έμ§λ³΄λ€ λ 빨리 kμ’νμ λμ°©ν κ°λ₯μ±μ΄ λκΈ°
λλ¬Έμ΄λ€. λλ¨Έμ§+1κ³Ό -1
λ κΈ°μ‘΄ μ’νμμ +1μ ν΄μ£Όμλ€. κ·Έλ¦¬κ³ λ€μ νμ μΆκ°νλ©΄μxκ° kμ κ°μ λ λ©μΆλλ‘
νλ€.νλ¦° μ΄μ
κ³±νκΈ° 2
μΈ κ²½μ° μ’νκ° λ€μ 0μ΄ λλ κ²½μ°κ° μκΈ΄λ€. -> λ°©λ¬Έμ νμΌλdist[nx]κ° μ¬μ ν 0μ΄ λλ€λ λ»μ΄λ€.
κ³ μΉ νμ΄
λ°©λ¬Έν κ²½μ° νΌλμ΄ μκΈ°μ§ μλλ‘ distμ λ°°μ΄μ λͺ¨λ 0μ΄ μλ
-1λ‘ μ€μ
νκ³ μμμμΉλ₯Ό 체ν¬νκΈ° μν΄dist[n]μ 0μΌλ‘ μ€μ νλ€.
λ°μ 쑰건문μμλ λ²μ μμ μμΌλ©°ν΄λΉ μ’νκ° -1μΌ λ (λ°©λ¬Ένμ§ μμλ€λ λ»)
λ‘ λ°κΎΈμ΄ μ£Όμλ€.π μλ‘κ² μκ²λ λ΄μ©
λ°©λ¬Ένμ§ μμμ λνλ΄κΈ° μν λ°°μ΄μ κ°μ λͺ¨λ 0μΌλ‘ μ€μ νμ λ, μμ μκ°μ΄ μλ κ²½μ°λ₯Ό μ²λ¦¬νμ§ λͺ»νλ―λ‘ -1λ‘ λ°κΎΈμ΄μ ν΄κ²°ν μ μμμ μ μ μμλ€.