-
Notifications
You must be signed in to change notification settings - Fork 5
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
26-LJEDD2 #103
Conversation
if graph[start][middle] != 1e9 and graph[middle][end] != 1e9: | ||
cost = graph[start][middle] + graph[middle][end] | ||
graph[start][end] = min(graph[start][end], cost) # μ§νμ΄λ κ²½μ λ λΉκ΅ν΄μ μ΅λ¨κ²½λ‘ μ λ°μ΄νΈ |
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.
μ΄μ°¨νΌ minκ°μΌλ‘ κ³μ κ°±μ νκΈ° λλ¬Έμ, INFκ° μλ κ²½μ°λΌκ³ κ΅³μ΄ μ‘°κ±΄μ κ±Έμ΄μ€ νμλ μκ² μ£ ?
graph[start][end] = min(graph[start][end], graph[start][middle] + graph[middle][end])
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.
μ΄λ²μ μ μλ λλΆμ μ΄λ¦λ§ λ€μλ νλ‘μ΄λ-μμ μκ³ λ¦¬μ¦ κ°λ μ μ²μ μκ² λμμ΅λλ€! μ²μμλ μ΄ν΄κ° μλΏμ§ μμλλ°
π€ μ½κ² λ§νμλ©΄ λΉμΌ λλ΄κ³ νμλ₯Ό ν κ²μ΄λ 1550μμΌλ‘ λ²μ€ νμΉ λλ²μ νλ... μλ° λλ !
λΆλΆμ μ½κ³ νμ€ν μ΄ν΄νκ² λμμ΅λλ€π§ κ°μ¬ν©λλΉπ
λν νλ‘μ΄λ κ°λ μ μ΄ν΄ν΄λ μ²μ μ ν΄λ³΄λ λ¬Έμ λΌ μ½μ§ μμμ΅λλ€,, κ·Έλμ λͺ μκ°μ λΆμ‘λ€κ° λ΅μ΄ μ보μ¬μ κ²°κ΅ μμΌλ‘ μ½λλ₯Ό λ°λΌ μμ±ν΄λ³΄κ³ μ½λμ λμ κ³Όμ μ μ΄ν΄νκ² λμμ΅λλ€π₯Ήπ₯Ή μμ§ μ΄ λΆλΆ μκ³ λ¦¬μ¦μ 곡λΆνκΈ°μλ λ©μμ§λ§ 곧 λ°λΌμ‘μμ νλ‘μ΄λ μκ³ λ¦¬μ¦μ λΏμ 보λλ‘ νκ² μ΅λλ€π
μ΄λ² PRλ μκ³ νμ ¨μ΄μ!π₯
|
||
for x in range(1, city+1): | ||
for y in range(1, city+1): | ||
if graph[x][y] == INF: |
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.
29λ² μ€μμλ 무νλλ₯Ό λνλ΄κΈ°μν΄ 1e9
λ₯Ό μ¬μ©νμλλ° μ¬κΈ°μλ INF
λ‘ λ¬΄νλλ₯Ό λνλΈ μ΄μ κ° μμκΉμ?
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.
ν μλ 1e9λ‘ μ¨λκ³ PRμΈλ INF λ³μλ₯Ό μλ‘ λ§λ€μλλ° μ½λ μμ μ΄ λ λμ΄μμκ΅°μ ! λ€μλ²μλ μ ... 체ν¬νκ² μ΅λλ€ ....
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.
μ€ μ μλ λλΆμ λ€μ΅μ€νΈλΌ μκ³ λ¦¬μ¦κ³Ό νλ‘μ΄λ μμ
λͺ¨λ μκ² λμμλλ€ ><
λ€μ΅μ€νΈλΌ μκ³ λ¦¬μ¦κ³Ό λ¬λ¦¬ μμμ§μ μ΄ μ ν΄μ Έμμ§ μκ³ , μ€κ° λ
Έλλ₯Ό κ±°μΉλ κ²½μ°λ κ³ λ €νλ€λ μ μ΄ ν₯λ―Έλ‘κ΅°μ π§π
π λ¬Έμ λ§ν¬
λ°±μ€ - μ΅λ¨ κ²½λ‘ μ°ΎκΈ° | νλ‘μ΄λ
λ¬Έμ μ€λͺ
μ ν 쑰건
βοΈ μμλ μκ°
1μκ°
β¨ μλ μ½λ
νκ·μ€μΉλμ κΈ°κ°λ§ν νλ‘μ΄λμμ κ°μλ₯Ό λ£κ³ λΈλ‘κ·Έμ λ°λ‘ TILμ μμ±νλ€.
π νλ‘μ΄λ-μμ (Floyd-Warshall) μκ³ λ¦¬μ¦μ΄λ?
Note
β¨ν΅μ¬ μμ΄λμ΄
π€ μ§μ λ μΆλ° μ§μ μμ λ€λ₯Έ μ§μ μΌλ‘ ν₯νλ μ΅μ λΉμ©μ ꡬνλ λ€μ΅μ€νΈλΌ μκ³ λ¦¬μ¦κ³Όλ λ€λ₯΄κ² μμμ§μ μ΄ μ ν΄μ Έμμ§ μλ€λ νΉμ§μ΄ μλ€!
π€ μΆλ°μ§μ μμ λͺ¨λ λμ°©μ§μ κΉμ§μ λͺ¨λ μ΅μλΉμ©μ κ³μ°νλ μκ³ λ¦¬μ¦μ΄λ€ !
-> ν μ μμ μ΄μ λ Έλλ₯Ό νμνλ©° μ΅λ¨ 거리λ₯Ό ꡬνλ λ€μ΅μ€νΈλΌ μκ³ λ¦¬μ¦κ³Όλ λ€λ₯΄κ², κ±°μ³κ°λ μ€κ° λ Έλλ₯Ό κΈ°μ€μΌλ‘ μ΅λ¨ 거리λ₯Ό ꡬνλ€λ μ !
π€ μ½κ² λ§νμλ©΄ λΉμΌ λλ΄κ³ νμλ₯Ό ν κ²μ΄λ 1550μμΌλ‘ λ²μ€ νμΉ λλ²μ νλ... μλ° λλ !
β
ꡬν λ°©λ²μ λ€μκ³Ό κ°λ€.
π€ λμμ리
1. μ΄κΈ°μΈν
2. λμ λ°©μ
β
3. κ²½μ μ μ μ§λλ μ΅λ¨κ±°λ¦¬
0λ² μ μ λΆν° kλ² μ μ κΉμ§λ§μ κ²½μ μ μΌλ‘ μΌμ λ uμμ vκΉμ§ κ°λ μ΅λ¨ κ²½λ‘μ κΈΈμ΄λ₯Ό μ°Ύλλ€.
μλ£κ΅¬μ‘° : 2μ°¨μ ν μ΄λΈ
μκ³ λ¦¬μ¦
B > C > A
μΌμλB > A
μΌμλ μλ€. λ°λΌμ λ κ° μ€ μ΅μκ° λλ κ°μ μ΅λ¨κ±°λ¦¬λ‘ κ°±μ νλ€.β ꡬν μ½λ
π μλ‘κ² μκ²λ λ΄μ©
[μκ³ λ¦¬μ¦/ κ·Έλν] λ€μ΅μ€νΈλΌ(Dijkstra) vs νλ‘μ΄λ μμ¬(Floyd Warshall) (JAVA)
νλ‘μ΄λ-μμ (Floyd-Warshall) μκ³ λ¦¬μ¦μ΄λ?