[알고리즘/백준] 1388번 : 바닥 장식(python)

유현민·2022년 3월 2일
0

알고리즘

목록 보기
26/253

가로 세로 따로 비교했다.

def solution(N, M, graph):
    count = 0

    for i in range(N):
        a = ''
        for j in range(M):
            if graph[i][j] == '-':
                if graph[i][j] != a:
                    count += 1
            a = graph[i][j]

    for j in range(M):
        a = ''
        for i in range(N):
            if graph[i][j] == '|':
                if graph[i][j] != a:
                    count += 1
            a = graph[i][j]

    print(count)


if __name__ == "__main__":
    N, M = map(int, input().split())
    graph = []
    for _ in range(N):
        graph.append(list(input()))
    solution(N, M, graph)
profile
smilegate megaport infra

0개의 댓글