λ¬Έμ
λ°±μ€ μ¨λΌμΈ μ μ§ - 11265λ²
νμ΄ κ³Όμ
κ·Έλνκ° μ£Όμ΄μ‘μ λ, μ΅μ μκ°μΌλ‘ κ° μ§μ κ°μ μ΄λ λΉμ©μ ꡬν λ€ μ ν μκ°λ΄μ λλ¬ κ°λ₯μ±μ νλ¨νλ λ¬Έμ μ
λλ€.νλ‘μ΄λ μμ¬ μκ³ λ¦¬μ¦
μ μ¬μ©ν΄μ λͺ¨λ μ μ κ°μ μ΅μ λΉμ©μ ꡬν λ€ μμ μ§μ κ³Ό λμ°© μ§μ μ νμ©ν΄μ λ΅μ ꡬν μ μμ΅λλ€.
μ½λ
import sys
def floyd(graph):
for k in range(N):
for i in range(N):
for j in range(N):
graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])
def solution(current_party, next_party, remaining_time):
is_possible = graph[current_party - 1][next_party - 1] <= remaining_time
return 'Enjoy other party' if is_possible else 'Stay here'
if __name__ == '__main__':
N, M = list(map(int, sys.stdin.readline().split()))
graph = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
participants = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
floyd(graph)
for participant in participants:
answer = solution(*participant)
print(answer)
λ°μν
'π algorithm > boj' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
BOJ 5980 - Corn Maze (0) | 2021.06.07 |
---|---|
BOJ 1240 - λ Έλμ¬μ΄μ 거리 (0) | 2021.06.07 |
BOJ 10472 - μμλ€μ§κΈ° (0) | 2021.04.18 |
BOJ 13908 - λΉλ°λ²νΈ (0) | 2021.04.13 |
BOJ 14940 - μ¬μ΄ μ΅λ¨κ±°λ¦¬ (0) | 2021.04.13 |
π¬ λκΈ