BOJ - 1058 - 친구

Updated:

def solution():
    N = int(input())

    friend = []
    visit = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        friend.append(list(str(input())))

    for i in range(N):
        for j in range(N):
            for k in range(N):
                if j == k: continue
                if friend[j][k] == "Y" or (friend[i][k] == "Y" and friend[j][i] == "Y"):
                    visit[j][k] = 1
    
    result = 0
    
    for v in visit:
        result = max(result, sum(v))
    print(result)
solution()

https://www.acmicpc.net/problem/1058

Categories:

Updated:

Leave a comment