플로이드와샬
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
parties = [list(map(int,input().split())) for _ in range(N)]
for k in range(N):
for i in range(N):
for j in range(N):
if parties[i][j] > parties[i][k] + parties[k][j]:
parties[i][j] = parties[i][k] + parties[k][j]
for _ in range(M):
A, B, C = map(int,input().split())
if parties[A-1][B-1] <= C:
print('Enjoy other party')
else:
print('Stay here')
'practivceAlgorithm > 백준' 카테고리의 다른 글
[백준][Python] 14627 파닭파닭 (0) | 2021.08.15 |
---|---|
[백준][Python] 15723 n단 논법 (0) | 2021.08.12 |
[백준][Python] 9372 상근이의 여행 (0) | 2021.08.12 |
[백준][Python] 18808 스티커 붙히기 (0) | 2021.08.11 |
[백준][Python] 20364 부동산 다툼. (1) | 2021.08.11 |