-
Notifications
You must be signed in to change notification settings - Fork 0
/
11265.py
29 lines (21 loc) ยท 969 Bytes
/
11265.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
# ์ ํ ์๊ฐ์ด 2์ด์ด๊ณ ์ต๋ ์ ์ ์ ๊ฐ์๊ฐ 500๊ฐ ์ด๊ธฐ ๋๋ฌธ์ ํด๋ก์ด๋ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก๋ ํ์ด ๊ฐ๋ฅ
# 1. ํด๋ก์ด๋ ์๊ณ ๋ฆฌ์ฆ
# ์ผ์ค for๋ฌธ์ ๋๋ฉฐ ์ต์๊ฐ์ผ๋ก map_์ ์ฑ์
# ์ต์ข
map_์ cost์ ์์ฒญํ cost๋ฅผ ๋น๊ตํ์ฌ ๋ต์ ์ถ๋ ฅ
# => ์๊ฐ ์ด๊ณผ => for๋ฌธ์ ๋๋ฆด ๋ ๋ณ์๋ฅผ ์ง์ ํ์ง ์๋ ๊ฒ์ผ๋ก ํด๊ฒฐ
import sys
N, M = map(int, sys.stdin.readline().split())
map_ = []
for row in range(N):
map_.append(list(map(int, sys.stdin.readline().split())))
for col in range(N):
if map_[row][col] == 0: map_[row][col] = 1000000001
for k in range(N):
for i in range(N):
for j in range(N):
if (map_[i][k] + map_[k][j]) < map_[i][j]: map_[i][j] = (map_[i][k] + map_[k][j])
for _ in range(M):
i, j, cost = map(int, sys.stdin.readline().split())
if map_[i-1][j-1] <= cost: print("Enjoy other party")
else: print("Stay here")