-
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
52-tgyuuAn #182
52-tgyuuAn #182
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.
μ μ λ¬Έμ μ§ νλ©΄μ λ΄€λ μμμ λ ¬ λ€μ 볡μ΅νκ³ κ°λλ€!!
μ²μμ λμμ 건물 μ¬λ¬κ°λ₯Ό μ§μ μ μλ€λκ±Έ λͺ¨λ₯΄κ³ νλ²μ νλμ© μ§λ μ€ μκ³ νμμ΅λλ€ γ
.γ
λ¬Έμ ν΄μμ μλͺ»ν΄λκ³€ μ νλ Έμ§?? νκ³ νμ°Έ λ΄€λ€μ;; γ
γ
γ
γ
λ¬Έμ νΈλλΌ κ³ μνμ ¨μ΄λ€ ~!!
N = int(input())
#걸리λ μκ° / λ¨Όμ μ§μ΄μ ΈμΌνλ 건물μ λ²νΈ
building = [list(map(int, input().split())) for _ in range(N)]
time = 0
result = [0 for _ in range(N+1)]
inDegree = [0 for _ in range(N+1)]
next_building = [[] for _ in range(N+1)]
q = []
for i in range(N):
time = building[i][0]
result[i+1] = time
for x in building[i][1:]:
if x != -1:
next_building[x].append(i+1)
inDegree[i+1] += 1
# μ§μ
μ°¨μκ° 0μ΄λ©΄ νμ λ£κΈ°
for i in range(1, N+1):
if inDegree[i] == 0:
heapq.heappush(q, i)
while q:
cur = heapq.heappop(q)
for i in next_building[cur]:
result[i] = max(result[i], result[cur]+building[i-1][0])
inDegree[i] -= 1
if inDegree[i] == 0:
heapq.heappush(q, i)
now = can_build.pop() | ||
|
||
for next_building in outdegree[now]: | ||
indegree[next_building][1].discard(now) |
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.
μ λ μ΄μ μ μ§μ΄μ ΈμΌ ν 건물μ κ·Έλ₯ listλ‘ μ μ₯ν΄μ μΌλλ°,, setμΌλ‘ μ μ₯ν΄λλ©΄ discardλ₯Ό μ¬μ©νλ©΄ λλκ΅°μ© ..
discard μ²μ 보λ€μ κ°μ μ‘΄μ¬ν¨μ΄ 보μ₯λλ©΄ remove(), 보μ₯λμ§ μμΌλ©΄ discard() μ€μ€ ν΄κ°λλ€!!
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.
κ·Όλ° μκ°ν΄λ³΄λ μμ μ§μ΄μ ΈμΌ ν 건물 λ²νΈλ₯Ό κ΅³μ΄ μ μ₯νμ§ μκ³ νμ₯¬λ₯΄κ° νΌ λ°©μλλ‘ indegree
λ‘λ§ κ΄λ¦¬νλ κ²μ΄ ν¨μ¬ μ’μ보μ΄λλ°μ?
μ΄μ°¨νΌ μμμ λ ¬μ΄λκΉ ν λ²μ©λ§ 건μ€λ ν λκΉ................................ κ΅μ₯ν΄ μμ²λ...............
0μΌλλ§ heapμ λ£κ² ν΄μ μ΄λ―Έ μ§μ΄μ§ 건물λ€μ μμλ‘ κ°λ²λ¦¬λκΉ... μμ°
μλ μμ μ λ ¬λ ν μ€ μλ μΈλμ΄μλ€....!! |
π λ¬Έμ λ§ν¬
κ²μ κ°λ°
βοΈ μμλ μκ°
20λΆ
β¨ μλ μ½λ
μ΄ λ¬Έμ , λ¬Έμ λ₯Ό μ½μ΄λ³΄λ©΄ μκ² μ§λ§ ACM Craftμ λ§€μ° λΉμ·νλ€. μλ κ°λ€.
#61 (comment)
5/8μΌ μμ νλ‘κ·Έλλ° κ²½μ§λνλ₯Ό μν΄μ μμμ λ ¬μ 볡기νλ λ§μμΌλ‘ λ€μ νμ΄λ³΄μλ°.
μ§μ§ κ·Όλ° νμ΄κ° μλ λ무 λκ°μμ... μΆκ°μ μΌλ‘ μΈ λ΄μ©μ΄ νν.
νμ£Όλνν λ μ£μ‘νμ§λ§ μμ μμμ λ ¬ κ΄λ ¨ν΄μ λ΄μ© λ€λ€λ€λ€ μ¨λ¨μΌλ μ½μ΄λ³΄κΈΈ μΆμ²νλ€!
ν€ν€ μ΄λ² PRμ λ λ¨Ήν΄μΌμ§
π μλ‘κ² μκ²λ λ΄μ©