BOJ - 1439 - 뒤집기

Updated:

import sys

def solution():
    S = sys.stdin.readline().strip()
    ret = []
    for i in range(1, len(S)):
        if S[i - 1] != S[i]:
            ret.append(i)
    flag = False
    if len(ret) % 2 == 1:
        flag = True

    result = len(ret) // 2
    if flag:
        result += 1
    print(result)

solution()

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

Categories:

Updated:

Leave a comment