<내 코드>
T = int(input())
for _ in range(T):
strings = list(input())
if strings[0] == 'O':
strings[0] = 1
else:
strings[0] = 0
for i in range(1, len(strings)):
if strings[i-1] != 'O' and strings[i] == 'O':
strings[i] = strings[i-1] + 1
else:
strings[i] = 0
print(sum(strings))
반응형
'알고리즘 문제풀기 > 백준 - Python' 카테고리의 다른 글
[백준 10026] 적록색약 - Python (DFS, BFS) (0) | 2020.09.03 |
---|---|
[백준 1987] 알파벳 - Python (DFS, 백트래킹) (0) | 2020.09.03 |
[백준 2667] 단지번호 붙이기 - Python (그래프, BFS) (0) | 2020.09.01 |
[백준 7576] 토마토 - Python (그래프, BFS) (0) | 2020.09.01 |
[백준 4963] 섬의 개수 - Python (그래프, BFS) (0) | 2020.08.31 |