본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 1388번 바닥 장식

by 현장 2022. 1. 12.

-코드

n, m = map(int, input().split())
arr = [list(input()) for _ in range(n)]
answer = 0
for i in range(n):
    l = 0
    for j in range(m):
        if arr[i][j] == '-':
            l += 1
            continue
        else:
            if l > 0:
                answer += 1
            l = 0
    if l > 0:
        answer += 1
for i in range(m):
    l = 0
    for j in range(n):
        if arr[j][i] == '|':
            l += 1
            continue
        else:
            if l > 0:
                answer += 1
            l = 0
    if l > 0:
        answer += 1
print(answer)