-
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
2-seongwon030 #7
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
κ°μλ₯Ό cnt
λ‘ λ°λ‘ λΆλ₯νμ¬ μ΅μ λ κ°μν΄μ£Όλ μμΌλ‘νμ¬ qκ° λΉμμ λ cnt
κ°μ λ°λΌ κ²°κ³Όλ₯Ό λ°νν΄μ€ μ μμ κ² κ°μ΅λλ€!
BFS λ¬Έμ λ€μ μ‘°κΈλ§ λμ΄λκ° μ¬λΌκ°κ² λλ©΄ μμΈ μ²λ¦¬λ₯Ό μ μ€νκ² μ μ°ΎμμΌνλλ° κΉλνκ² μ μ°Ύμλ΄μ 보기 μ’μλ κ² κ°μ΅λλ€!
ν λ§ν λ 3μ°¨μλ μ‘΄μ¬νλ€λ κ±° μμλμ? λ§μλ ν λ§ν ! λ¬Έμ μΆμ² λ립λλ€!
μ΅μ ν λ§ν μ μμΉλ§ κ³ λ €ν΄μ μκ°λ³΅μ‘λλ₯Ό κ³ λ €νμ§λ λͺ»νλ€μ.. κ°μ¬ν©λλ€!! 3μ°¨μλ ν λ² νλ¬ κ°λ³΄κ² μ΅λλ€ γ γ |
11μ°¨μ ν λ§ν λ μλ€λ κ² μμλμ? νμ΄νΌ ν λ§ν λ€λ₯Έ μ½λ λΆλΆλ μ΄ν΄νκΈ° μ¬μμ μ’μμ΅λλ€. |
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.
μ½λ μ λ΄€μ΅λλ€ :)
λ€μμ flagμμ΄λ μ§ λ΄μΌκ² λ€μ! λ¬Έμ μΆμ² κ°μ¬ν©λλ€ γ γ |
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λ₯Ό ν΄μ£Όκ³ λμ μμ΅μ ν λ§ν κ° μλμ§ νμΈνκΈ° μν΄
λ€μ νμνλ κ³Όμ μμ μ’ νλ€μλ κ²½νμ΄μλ€μ.. κΉλν μ½λ μ λ³΄κ³ κ°λλ€ !
π λ¬Έμ λ§ν¬
ν λ§ν
βοΈ μμλ μκ°
1μΌ
β¨ μλ μ½λ
첫λ²μ§Έ νμ΄
2μ°¨μλ°°μ΄
λ‘ μ μ₯μνμ’μ°
λ‘ λλ 리μ€νΈ μ€μ append
append
νκ° λΉμ΄μμ λκΉμ§ λ°λ³΅
0μΈ κ°μ΄ μμΌλ©΄ -1μ μΆλ ₯νκ³ exit.
ans-1
λ¬Έμ μ
=> -1μΌ λ κ³μ μΆλ ₯νλ λ¬Έμ
λλ²μ§Έ νμ΄
flag μ λΆλ¦¬μΈ κ°μΈ false
λ‘ μ μ₯flagλ₯Ό Trueλ‘ λ°κΎΈκ³ break
π μλ‘κ² μκ²λ λ΄μ©
xμ yμ’νλ₯Ό λͺ¨λ μ¬μ©ν΄μ μ΄λνλ κ²½μ°λ μ²μ μ ν΄λ΄€κ³ 2μ°¨μ 리μ€νΈλ₯Ό μ΄μ©ν΄ ν μ μλκ² μ°Έμ νλ€.