Skip to content

Commit

Permalink
2024-09-25 친구.py
Browse files Browse the repository at this point in the history
  • Loading branch information
LJEDD2 committed Sep 27, 2024
1 parent a3c8118 commit 5522154
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LJEDD2/플로이드 워셜/친구.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
input = sys.stdin.readline

n = int(input())
graph = [list(input().strip()) for _ in range(n)]
visited = [[0] * n for _ in range(n)]

for k in range(n):
for i in range(n):
for j in range(n):
if i == j:
continue

# 2-친구인 경우
if graph[i][j] == 'Y' or (graph[i][k] == 'Y' and graph[k][j] == 'Y'):
visited [i][j] = 1

res = 0
for row in visited:
res = max(res,sum(row))
print(res)

0 comments on commit 5522154

Please sign in to comment.