按照题意直接模拟即可,时间复杂度O(n)
n = int(input())
for _ in range(n):
a = input().strip()
lena = len(a)
s = 0
for i in range(lena-1):
if a[i] == a[i+1]:
s += 1
print(s+lena)
按照题意直接模拟即可,时间复杂度O(n)
n = int(input())
for _ in range(n):
a = input().strip()
lena = len(a)
s = 0
for i in range(lena-1):
if a[i] == a[i+1]:
s += 1
print(s+lena)